Files
AIclinicalresearch/backend/prisma/migrations/20260309_add_aia_attachments_persistence/migration.sql
HaHafeng 5c5fec52c1 fix(aia,ssa,asl,infra): harden SSE transport and stabilize attachment context
Deliver SSE protocol hardening for SAE/HTTP2 paths, add graceful shutdown health behavior, and improve SSA retry UX for transient stream failures. For AIA, persist attachment extraction results in database with cache read-through fallback, plus production cache safety guard to prevent memory-cache drift in multi-instance deployments; also restore ASL SR page scrolling behavior.

Made-with: Cursor
2026-03-09 18:45:12 +08:00

31 lines
1.1 KiB
SQL

-- AIA 附件持久化:数据库真相源 + 缓存加速
CREATE TABLE IF NOT EXISTS "aia_schema"."attachments" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"conversation_id" TEXT NOT NULL,
"filename" TEXT NOT NULL,
"mime_type" TEXT,
"size" INTEGER NOT NULL,
"oss_url" TEXT NOT NULL,
"text_content" TEXT,
"extract_status" TEXT NOT NULL DEFAULT 'success',
"extract_error" TEXT,
"token_count" INTEGER NOT NULL DEFAULT 0,
"truncated" BOOLEAN NOT NULL DEFAULT false,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "attachments_pkey" PRIMARY KEY ("id")
);
CREATE INDEX IF NOT EXISTS "idx_aia_attachments_conversation_id"
ON "aia_schema"."attachments"("conversation_id");
CREATE INDEX IF NOT EXISTS "idx_aia_attachments_user_id"
ON "aia_schema"."attachments"("user_id");
CREATE INDEX IF NOT EXISTS "idx_aia_attachments_extract_status"
ON "aia_schema"."attachments"("extract_status");
CREATE INDEX IF NOT EXISTS "idx_aia_attachments_created_at"
ON "aia_schema"."attachments"("created_at");