2023-10-04 21:16:32 +00:00
|
|
|
CREATE TABLE "notification_kinds" (
|
2023-10-13 00:17:45 +00:00
|
|
|
"id" SERIAL PRIMARY KEY,
|
2023-10-06 19:56:18 +00:00
|
|
|
"name" VARCHAR NOT NULL
|
2023-10-04 21:16:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX "index_notification_kinds_on_name" ON "notification_kinds" ("name");
|
|
|
|
|
|
|
|
CREATE TABLE notifications (
|
|
|
|
"id" SERIAL PRIMARY KEY,
|
2023-10-13 00:17:45 +00:00
|
|
|
"is_read" BOOLEAN NOT NULL DEFAULT FALSE,
|
2023-10-04 21:16:32 +00:00
|
|
|
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
2023-10-06 19:56:18 +00:00
|
|
|
"recipient_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
2023-10-13 00:17:45 +00:00
|
|
|
"actor_id" INTEGER REFERENCES users (id) ON DELETE CASCADE,
|
2023-10-04 21:16:32 +00:00
|
|
|
"kind" INTEGER NOT NULL REFERENCES notification_kinds (id),
|
2023-10-13 00:17:45 +00:00
|
|
|
"content" TEXT
|
2023-10-04 21:16:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX "index_notifications_on_recipient_id" ON "notifications" ("recipient_id");
|