All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
## 数据模型 - ChatSession +13 字段 (scopeType/scopeId/parentKnowledgeBaseId/createdFrom/isPinned/isArchived/isDeleted/modelMode/modelId/lastMessageAt) - ChatMessage +scopeSnapshot (消息级 scope 快照) - ChatCitation +lineStart/lineEnd +sourceId 索引 - 5 个新查询索引 ## 核心能力 - open-or-create: 同 scope 继续会话 (200) / 新建 (201) - scope 级检索: global/knowledge_base/material/knowledge_item/folder - listSessions: scope 过滤 + isDeleted 排除 + isPinned 排序 + 分页元数据 - 自动标题: 首条消息截取 + 词边界处理 - 软删除 + 置顶/归档 - scope 字段创建后不可修改 - 全部端点 userId 鉴权 ## 文档 - docs/chat-scope-design.md (设计文档 + 决策表) - docs/chat-scope-api-contract.md (API 契约) - docs/chat-scope-test-plan.md (33 条测试用例) - prisma/migrations/backfill_chat_scope.sql (旧数据回填) ## Bug 修复 - #104: KnowledgeItem.sourceRef 填充 (material scope 检索修复) - #102: sendMessageStream aiGateway null 保护 - listSessions isDeleted/isArchived 过滤 + 分页 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
21 lines
882 B
SQL
21 lines
882 B
SQL
-- ============================================================
|
||
-- M7-10: ChatScope 旧数据回填
|
||
-- 将 M-CHAT 里程碑前创建的旧会话补全 scope 字段
|
||
-- 可重复执行(idempotent):只更新 scopeId IS NULL 的记录
|
||
-- ============================================================
|
||
|
||
-- 1. 回填 scope 字段
|
||
UPDATE "ChatSession"
|
||
SET
|
||
"scopeType" = 'knowledge_base',
|
||
"scopeId" = "knowledgeBaseId",
|
||
"parentKnowledgeBaseId" = "knowledgeBaseId",
|
||
"createdFrom" = 'legacy_migration',
|
||
"lastMessageAt" = COALESCE("lastMessageAt", "updatedAt")
|
||
WHERE "scopeId" IS NULL
|
||
AND "scopeType" = 'knowledge_base'; -- 默认值
|
||
|
||
-- 2. 验证
|
||
-- SELECT COUNT(*) AS backfilled_count FROM "ChatSession" WHERE "createdFrom" = 'legacy_migration';
|
||
-- SELECT id, title, "scopeType", "scopeId", "parentKnowledgeBaseId", "createdFrom" FROM "ChatSession" WHERE "scopeId" IS NULL;
|