mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
database fix (broke migrations!)
This commit is contained in:
parent
f448d2c0c8
commit
0306b6737a
@ -1,5 +0,0 @@
|
||||
-- upgrade --
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
ALTER TABLE "bot" ADD "code" UUID NOT NULL DEFAULT uuid_generate_v4();
|
||||
-- downgrade --
|
||||
ALTER TABLE "bot" DROP COLUMN "code";
|
@ -14,10 +14,12 @@ CREATE TABLE IF NOT EXISTS "bot" (
|
||||
"id" SERIAL NOT NULL PRIMARY KEY,
|
||||
"token" VARCHAR(50) NOT NULL UNIQUE,
|
||||
"name" VARCHAR(33) NOT NULL,
|
||||
"code" UUID NOT NULL,
|
||||
"start_text" TEXT NOT NULL,
|
||||
"group_chat_id" INT REFERENCES "group_chat" ("id") ON DELETE SET NULL,
|
||||
"group_chat_id" INT REFERENCES "group_chat" ("id") ON DELETE CASCADE,
|
||||
"owner_id" INT NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "idx_bot_code_a43015" ON "bot" ("code");
|
||||
CREATE TABLE IF NOT EXISTS "aerich" (
|
||||
"id" SERIAL NOT NULL PRIMARY KEY,
|
||||
"version" VARCHAR(255) NOT NULL,
|
||||
@ -25,6 +27,6 @@ CREATE TABLE IF NOT EXISTS "aerich" (
|
||||
"content" JSONB NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "bot_group_chat" (
|
||||
"bot_id" INT NOT NULL REFERENCES "bot" ("id") ON DELETE SET NULL,
|
||||
"groupchat_id" INT NOT NULL REFERENCES "group_chat" ("id") ON DELETE SET NULL
|
||||
"bot_id" INT NOT NULL REFERENCES "bot" ("id") ON DELETE CASCADE,
|
||||
"groupchat_id" INT NOT NULL REFERENCES "group_chat" ("id") ON DELETE CASCADE
|
||||
);
|
@ -15,9 +15,10 @@ class Bot(Model):
|
||||
Напишите ваш вопрос и мы ответим вам в ближайшее время.
|
||||
"""))
|
||||
|
||||
group_chats = fields.ManyToManyField("models.GroupChat", related_name="bots", on_delete=fields.relational.SET_NULL)
|
||||
group_chats = fields.ManyToManyField("models.GroupChat", related_name="bots", on_delete=fields.relational.CASCADE,
|
||||
null=True)
|
||||
group_chat = fields.ForeignKeyField("models.GroupChat", related_name="active_bots",
|
||||
on_delete=fields.relational.SET_NULL,
|
||||
on_delete=fields.relational.CASCADE,
|
||||
null=True)
|
||||
|
||||
async def super_chat_id(self):
|
||||
|
Loading…
Reference in New Issue
Block a user