feat(0.2.1): M5 闭环验证通过 —— verify 脚本 7 步全绿 (下行/离线写/上行/定号/回填/REST确认/删除同步); 方案文档补 Sequential ID Mapping
This commit is contained in:
@@ -51,6 +51,15 @@
|
||||
- 主键仍为自增 Int,业务外键不动;客户端上行一律以 uuid 引用父子行,服务端解析为内部 id;
|
||||
- Prisma datasource: `mysql` → `postgresql`;本分支重建基线迁移(旧 MySQL 迁移文件移除,历史保留在 git)。
|
||||
|
||||
### 3.1 Sequential ID Mapping(落地时按官方模式补充)
|
||||
|
||||
按 PowerSync 官方 [Sequential ID Mapping](https://docs.powersync.com/client-sdks/advanced/sequential-id-mapping) 模式实施,解决"离线新建行同步回填后本地 id 变化"问题:
|
||||
|
||||
- 任务域 6 表再加**外键 uuid 镜像列**(`Task.projectUuid/columnUuid/parentUuid`、`BoardColumn.projectUuid`、`ProjectMember.projectUuid`、`TaskMember/TaskTag.taskUuid`),由 **PG 触发器**在写入时按 int 外键自动回填(迁移 `20261026010000_uuid_fk_mapping`),库级 NOT NULL;
|
||||
- Sync Streams 以 **`uuid` 作为客户端主键**(`SELECT "uuid" AS "id"`),镜像列别名输出回 `projectId/columnId/parentId/taskId` —— 客户端 schema 与页面代码**零改动**;
|
||||
- 服务端 upload 处理器按 uuid 解析父行(`findUnique({ where: { uuid } })`),解析后再写 int 外键 → 触发器回填镜像,两侧闭环一致;
|
||||
- 镜像列在 Prisma 模型中声明为可空(触发器保证库级非空),避免 create 校验拦截。
|
||||
|
||||
## 4. 同步与冲突
|
||||
|
||||
- Sync Rules 仅下发任务域 6 表 + `User`(展示名称/头像用),按 `ProjectMember.userId = auth.parameters.userId` 过滤项目可见性;时序/监控/米家等表不纳入;
|
||||
|
||||
Reference in New Issue
Block a user