docs(wiki): 全景梳理 — 更新 9 个 wiki + CLAUDE.md scope + 头脑风暴记录
Some checks failed
CI / security-audit (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled

基于 3 个并行探索代理的全面扫描结果,更新 wiki 数据至实际状态:
- index.md: 18 crate / 76 迁移 / 44 实体 / 77k 行 / 409 提交
- erp-health.md: 44 实体 / 21 handler / 22 权限 / 25 事件 / 6 消费者
- erp-server.md: 9 后台任务 / RLS 中间件栈
- architecture.md: 新增 erp-ai/dialysis 到依赖图 / 测试覆盖表
- testing.md: 225 单元 + 159 集成 / 4 模块零测试警告
- database.md: 76 迁移 / RLS+哈希链+盲索引+Dead Letter
- erp-core.md: PiiCrypto 加密体系 / EventBus 完整描述
- frontend.md: 163 文件 / 5 store / 10 API 文件
- CLAUDE.md: 新增 health/ai/dialysis/assessment scope

头脑风暴 4 个议题决策:
- dialysis: 接入激活
- 测试: 按风险排序(workflow > ai > message > config)
- AI: 数据桥接优先
- 路线图: AI 驱动 3 个月 5 Phase
This commit is contained in:
iven
2026-04-28 14:53:04 +08:00
parent ac1033dbaf
commit 75cd305996
10 changed files with 359 additions and 91 deletions

View File

@@ -1,6 +1,6 @@
---
title: 数据库迁移与模式
updated: 2026-04-26
updated: 2026-04-28
status: stable
tags: [database, seaorm, migration, multi-tenant]
---
@@ -24,7 +24,7 @@ tags: [database, seaorm, migration, multi-tenant]
| 文件 | 职责 |
|------|------|
| `crates/erp-server/migration/src/lib.rs` | Migrator 注册所有迁移 |
| `crates/erp-server/migration/src/m*.rs` | 72 个迁移文件 |
| `crates/erp-server/migration/src/m*.rs` | 76 个迁移文件 |
| `crates/erp-core/src/types.rs` | BaseFields 标准字段定义 |
### 迁移命名规则
@@ -81,6 +81,20 @@ m{YYYYMMDD}_{6位序号}_{描述}.rs
| m000064-000068 | PII 加密扩展patient/consultation/follow_up/family_member/doctor_profile |
| m000069-000071 | 加密字段 key_versiondialysis_record/lab_report/diagnosis |
| m000072 | 拓宽加密手机号列 |
| m000073-000075 | 设备数据采集device_readings |
| m000076 | 告警系统alerts, alert_rules |
| m000077 | 危急值告警critical_alert, critical_alert_response |
| m000078-000079 | 随访模板follow_up_template, follow_up_template_field |
| m000080 | 用药记录medication_record |
| m000081 | 透析处方增强 |
| m000082 | AI 用量统计表增强 |
| m000083-000085 | 索引和约束优化 |
| m000086 | 启用 RLS 所有表 |
| m000087 | 审计日志哈希链 |
| m000088 | RLS 严格策略FORCE |
| m000089 | 盲索引blind_index 表) |
| m000090 | 告警阈值表增强 |
| m000091 | Dead Letter 事件表 |
### 集成契约
@@ -89,7 +103,7 @@ m{YYYYMMDD}_{6位序号}_{描述}.rs
| 消费 ← | [[erp-server]] | 启动时自动运行 `Migrator::up()` |
| 依赖 ← | [[erp-core]] | BaseFields 定义标准字段规范 |
| 提供 → | 所有业务模块 | 表结构供 SeaORM Entity 使用 |
| 提供 → | [[erp-health]] | 34 张健康业务表 |
| 提供 → | [[erp-health]] | 44 张健康业务表 |
## 3. 代码逻辑
@@ -131,6 +145,7 @@ m{YYYYMMDD}_{6位序号}_{描述}.rs
| 日期 | 变更 |
|------|------|
| 2026-04-28 | 更新至 76 迁移,新增设备采集/告警/RLS/审计哈希链/盲索引/Dead Letter/透析处方等 19 个迁移 |
| 2026-04-26 | 更新至 72 迁移、67+ 表,新增积分商城/透析/诊断/内容管理/线下活动/PII 加密扩展等 22 个迁移 |
| 2026-04-25 | 更新至 50 迁移、48 表新增健康模块迁移m000042-m000050和 18 张健康业务表 |
| 2026-04-23 | 重构为 5 节结构,更新表清单至 41 个迁移 |