Files
X-Financial/document/development/2026-07-18/dev-logs/bugs/tenant-identity-global-unique-indexes.md

15 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 员工与组织残留全局唯一索引阻断多租户复用
日期2026-07-18
文档路径document/development/2026-07-18/dev-logs/bugs/tenant-identity-global-unique-indexes.md
## 修复记录
- 15:54记录数据库迁移修复员工编号、员工邮箱和组织编码仍保留单列全局唯一索引第二个企业无法使用相同企业内部标识。
- Git 提交检查:`git fetch --all --prune` 成功upstream `origin/main` 无新提交;本地 ahead 19 条,最新为 `07241b46 fix(docker): manage local postgres in default compose``787bc3a4 feat(platform): close AI expense value loop``242d68c3 feat(approval): add task workflow and waiver decisions`,另有 16 条。
- 原因历史迁移已增加正确的租户复合唯一约束但三个旧单列唯一索引未被替换PostgreSQL 仍按全局范围拒绝重复值。
- 修改:新增 Alembic `20260718_0029`,在 PostgreSQL 中校验复合唯一约束和现有索引形态后,将三个同名单列唯一索引替换为普通查询索引;降级前检查跨租户重复并在无法安全恢复全局唯一时拒绝降级。
- 操作:更新迁移前置检查和迁移测试;只读核验当前数据库仍位于 `20260717_0028`,未执行 live DDL、数据写入或主容器重启。
- 验证:容器内迁移测试 `167 passed, 1 skipped`Ruff 通过Alembic HEAD 为 `20260718_0029`;跳过项仅因未配置专用一次性 PostgreSQL 迁移测试库,未使用当前业务库替代。
- 影响:代码层已具备租户内唯一、跨租户可复用的索引迁移;正式生效会短暂获取索引 DDL 锁,须在用户确认维护窗口后应用。