文档(会员目录):明确懒播种策略与只读入口首次写库的副作用

- ensure_default_profile_membership_plan 注释说明 init 与读取 helper 共用、目录空时首次读取会写库
- init_profile_membership_plan_catalog 注释改为不覆盖「表已存在但为空」的存放量库
- 报价与建单注释去掉「不写库」的绝对说法,注明目录空时的懒播种例外
- 同步设计文档 7 / 10.2 与决策日志(播种策略定为保留懒播种 + 明示副作用)
This commit is contained in:
2026-10-04 13:20:06 +08:00
parent fdf636ce95
commit 9d7ca1b3b7
3 changed files with 34 additions and 7 deletions
@@ -471,6 +471,7 @@ flowchart TD
- 旧充点行不删除(复用 id 并去掉赠送);首充资格与历史订单继续可读。
- 旧会员档位枚举与会员商品行**删除**(会员侧未上线,无需兼容)。
- **不做** `tier → plan` 回填;若实施时发现意外存量会员行,先停下评估再补。
- 会员目录播种(第 20 项结论 = 保留懒播种):`init` 只在首次创建库时跑,增量发布不重跑;「表存在但为空」的存量库靠读取 helper 懒播种,代价是只读入口首次调用会写库。若要彻底移除副作用,需先把播种改到发布期 migration,再删懒播种——当前不做。
- 钱包侧(总额、每日免费、永久余数、账本)口径不允许漂移;充点订单不允许破坏性变更。
---
@@ -528,7 +529,11 @@ flowchart TD
- 会员领域模块 `module-runtime/src/membership/{catalog,cycle,limits,upgrade}.rs`,公历基元抽为 `civil_calendar`。
- 账本来源枚举末尾追加 `MembershipUpgradeGrant`,并同步契约常量、后台索引映射、前端来源标签与生成绑定。
- 新增表 `profile_membership_plan`(主键为档位枚举 `RuntimeProfileMembershipPlan`),同步 `migration.rs`、表目录与生成绑定;
播种 `ensure_default_profile_membership_plan`:表为空时按代码内目录整表播种,表非空时保留后台改价。
播种策略:表为空时按代码内目录整表播种,表非空时保留后台改价。
`#[reducer(init)] init_profile_membership_plan_catalog` 只在数据库首次创建时执行一次(增量发布不重跑),
因此「表已存在但为空」的存量库由读取 helper `membership_plan_row` / `membership_plan_records` 里的
`ensure_default_profile_membership_plan` 懒播种兜底。**副作用**:报价 / 充值中心 / 后台查询等只读入口在
目录为空的首次调用会写库,表非空后保持只读;这是有意保留的策略,见 §7。
- 删列与清退:`profile_membership` 去掉 `tier` / `cycle_period_days`、追加
`plan` / `cycle_index` / `cycle_count` / `cycle_kind`;`profile_recharge_product_config` 去掉
`tier` 与四个 `membership_*` 字段;`RuntimeProfileMembershipTier`、会员权益矩阵、