forked from mtusi2026/mtusi2026lab4
feat(storage): add RustFS attachments and presigned uploads
Add two API replicas, safe object reconciliation, upload validation, regression tests and documented load experiments.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
ALTER TABLE "messages" ADD COLUMN "attachment_ids" UUID[] NOT NULL DEFAULT ARRAY[]::UUID[];
|
||||
|
||||
CREATE TABLE "attachments" (
|
||||
"id" UUID NOT NULL,
|
||||
"chat_id" UUID NOT NULL,
|
||||
"owner_id" UUID NOT NULL,
|
||||
"object_key" TEXT NOT NULL,
|
||||
"filename" VARCHAR(255) NOT NULL,
|
||||
"content_type" VARCHAR(32) NOT NULL,
|
||||
"size_bytes" INTEGER NOT NULL CHECK ("size_bytes" BETWEEN 1 AND 10485760),
|
||||
"sha256" CHAR(64) NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "attachments_pkey" PRIMARY KEY ("id"),
|
||||
CONSTRAINT "attachments_chat_id_fkey" FOREIGN KEY ("chat_id") REFERENCES "chats"("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "attachments_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
CREATE UNIQUE INDEX "attachments_object_key_key" ON "attachments"("object_key");
|
||||
CREATE INDEX "attachments_chat_id_idx" ON "attachments"("chat_id");
|
||||
CREATE INDEX "attachments_owner_id_idx" ON "attachments"("owner_id");
|
||||
Reference in New Issue
Block a user