1.3 KiB
1.3 KiB
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 依次删除配置、绑定和应用表,再由旧迁移回滚基础表。