Files
mtusi2026lab4/prisma/migrations/20261110000000_direct_uploads/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

21 lines
1.1 KiB
SQL

CREATE TYPE "direct_upload_status" AS ENUM ('pending', 'completed', 'rejected', 'expired');
CREATE TABLE "direct_uploads" (
"id" UUID NOT NULL,
"chat_id" UUID NOT NULL,
"owner_id" UUID NOT NULL,
"filename" VARCHAR(255) NOT NULL,
"content_type" VARCHAR(32) NOT NULL,
"size_bytes" INTEGER NOT NULL,
"sha256" CHAR(64) NOT NULL,
"status" "direct_upload_status" NOT NULL DEFAULT 'pending',
"expires_at" TIMESTAMPTZ(3) NOT NULL,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "direct_uploads_pkey" PRIMARY KEY ("id"),
CONSTRAINT "direct_uploads_chat_id_fkey" FOREIGN KEY ("chat_id") REFERENCES "chats"("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "direct_uploads_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "direct_uploads_size_check" CHECK ("size_bytes" BETWEEN 1 AND 10485760)
);
CREATE INDEX "direct_uploads_status_expires_at_idx" ON "direct_uploads"("status", "expires_at");
CREATE INDEX "direct_uploads_chat_id_idx" ON "direct_uploads"("chat_id");
CREATE INDEX "direct_uploads_owner_id_idx" ON "direct_uploads"("owner_id");