docs(M02-A): 记录多租户模型验收结果

This commit is contained in:
Codex
2026-06-18 10:31:16 +08:00
parent 8b8fb28c36
commit 0db9505553
7 changed files with 103 additions and 11 deletions
@@ -0,0 +1,23 @@
# M02-A 多小程序与租户配置模型
- 迁移版本:`2026061803`
- Up`database/migrations/2026061803_m02a_tenant_apps.up.sql`
- Down`database/migrations/2026061803_m02a_tenant_apps.down.sql`
- Verify`database/migrations/2026061803_m02a_tenant_apps.verify.sql`
## 新增表
| 表 | 用途 | 隔离约束 |
|---|---|---|
| `qipai_platform_apps` | 微信 AppID 对应的逻辑应用 | AppID 全局唯一 |
| `qipai_tenant_apps` | 应用与租户绑定 | 唯一键包含 `tenant_id, platform_app_id` |
| `qipai_tenant_configs` | 品牌、Logo、主题、电话、分享和默认门店配置 | 唯一键包含 `tenant_id, platform_app_id` |
`qipai_tenants` 沿用 M01-B 已建立的租户主表,不重复创建第二套 tenant 表。配置查询必须同时通过有效 AppID、有效绑定和明确租户条件;一个 AppID 绑定多个租户时,未传 `tenant-id` 的请求会被拒绝。
## 验证与回滚
- Windows:后端构建、迁移契约和仓储/API 注入测试通过。
- WSL MySQL 8.4.9:临时库执行 `up → verify → down → up → verify` 通过。
- 实测同一 AppID 绑定两个租户时,可分别读取独立品牌配置;跨租户 ID 返回空,省略租户 ID 返回冲突错误。
- Down 依次删除配置、绑定和应用表,再由旧迁移回滚基础表。