feat(api,db-cn): persist synced source profile snapshot on mappings

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-22 17:33:27 +08:00
parent ccf0c29659
commit f6ff1d44f2
6 changed files with 99 additions and 4 deletions
@@ -0,0 +1,7 @@
-- G4 后续:映射表增 profile JSON 列——同步源档案快照(工号/邮箱/公司/头像),
-- 纯展示维度:不参与同步决策(引擎幂等仍只看 sourceVersion),users 表零改动
-- (源身份隔离红线,见 user-source.port.ts / user-sync.service.ts 文件头)。
-- nullable:mock 源/历史行无快照;存量行由引擎「幂等跳过路径的展示补偿写」
-- 在下批同步自然回填(版本门跳过但 profile 缺失/变化时仅刷映射行)。
-- JSON 列无 collation,不涉 utf8mb4_0900_bin 手决项。
ALTER TABLE `external_user_mappings` ADD COLUMN `profile` JSON NULL;
+1
View File
@@ -319,6 +319,7 @@ model external_user_mappings {
sourceSystem String @default("mock") @db.VarChar(32) // G4 后换真实源标识
externalUserId String @db.VarChar(64)
sourceVersion Int @default(0) // 幂等比较位:仅更高版本应用
profile Json? // 同步源档案快照(工号/邮箱/公司/头像)——纯展示,不参与同步决策(users 表零改动红线)
createdAt DateTime @default(now()) @db.DateTime(6)
@@unique([sourceSystem, externalUserId])