Files
mtusi2026lab4/prisma/migrations/20261013150000_message_epoch_buckets/migration.sql
T
qrtx dc46ac213d feat(storage): add RustFS attachments and presigned uploads
Add two API replicas, safe object reconciliation, upload validation, regression tests and documented load experiments.
2026-11-12 10:16:39 +03:00

14 lines
601 B
SQL

CREATE TABLE "chat_message_epochs" (
"chat_id" UUID NOT NULL,
"bucket" SMALLINT NOT NULL,
"epoch" BIGINT NOT NULL DEFAULT 0,
CONSTRAINT "chat_message_epochs_pkey" PRIMARY KEY ("chat_id", "bucket"),
CONSTRAINT "chat_message_epochs_bucket_check" CHECK ("bucket" BETWEEN 0 AND 15),
CONSTRAINT "chat_message_epochs_chat_id_fkey" FOREIGN KEY ("chat_id") REFERENCES "chats"("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "chat_message_epochs" ("chat_id", "bucket", "epoch")
SELECT "id", 0, "messages_epoch" FROM "chats";
ALTER TABLE "chats" DROP COLUMN "messages_epoch";