2023-07-28 21:56:02 +00:00
|
|
|
DROP TABLE "channel_messages";
|
|
|
|
DROP TABLE "channel_memberships";
|
|
|
|
DROP TABLE "org_memberships";
|
|
|
|
DROP TABLE "orgs";
|
|
|
|
DROP TABLE "channels";
|
|
|
|
|
2023-07-27 00:20:43 +00:00
|
|
|
CREATE TABLE "channels" (
|
|
|
|
"id" SERIAL PRIMARY KEY,
|
|
|
|
"name" VARCHAR NOT NULL,
|
2023-07-28 21:56:02 +00:00
|
|
|
"created_at" TIMESTAMP NOT NULL DEFAULT now()
|
|
|
|
);
|
2023-07-27 00:20:43 +00:00
|
|
|
|
2023-08-09 17:36:27 +00:00
|
|
|
CREATE TABLE "channel_paths" (
|
|
|
|
"id_path" VARCHAR NOT NULL PRIMARY KEY,
|
|
|
|
"channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE
|
2023-07-28 21:56:02 +00:00
|
|
|
);
|
2023-08-09 17:36:27 +00:00
|
|
|
CREATE INDEX "index_channel_paths_on_channel_id" ON "channel_paths" ("channel_id");
|
2023-07-27 00:20:43 +00:00
|
|
|
|
|
|
|
CREATE TABLE "channel_members" (
|
|
|
|
"id" SERIAL PRIMARY KEY,
|
|
|
|
"channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
|
|
|
|
"user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
|
|
|
"admin" BOOLEAN NOT NULL DEFAULT false,
|
2023-07-29 00:05:56 +00:00
|
|
|
"accepted" BOOLEAN NOT NULL DEFAULT false,
|
2023-07-28 21:56:02 +00:00
|
|
|
"updated_at" TIMESTAMP NOT NULL DEFAULT now()
|
|
|
|
);
|
2023-07-27 00:20:43 +00:00
|
|
|
|
|
|
|
CREATE UNIQUE INDEX "index_channel_members_on_channel_id_and_user_id" ON "channel_members" ("channel_id", "user_id");
|
2023-07-31 22:27:10 +00:00
|
|
|
|
|
|
|
ALTER TABLE rooms ADD COLUMN "channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE;
|