fix(迁移): 补齐会员重构的破坏性迁移导入兼容

- migration.rs 为旧迁移包回填 profile_membership 的 plan / cycle_index / cycle_count / cycle_kind 默认值。

- migration.rs 为旧迁移包回填 profile_recharge_order 的 14 个 membership_* 快照默认值,避免回灌导入因缺列失败。

- 新增两条单元测试守护会员表与订单快照的旧包默认值。

- 同步后端架构文档的 profile_membership / profile_recharge_product_config / profile_recharge_order 表目录。

- 记录 SpacetimeDB 2.8.3 持久表删列需显式迁移的实测结论与既有 run_conflict_migration_publish 路径。
This commit is contained in:
2026-10-03 17:11:04 +08:00
parent 1a106eadef
commit 21f69ef13b
3 changed files with 153 additions and 4 deletions
@@ -181,6 +181,16 @@ pub struct ProfileMembershipPlan {
**回退为「保留列 + 写死默认值 + 运行时不读」**,并在生成绑定与表目录里明确标注为废弃残留。
两种路径都必须先让 schema 门禁通过,不得使用 `--delete-data=always` 绕过。
**实测结论(2026-10-03,SpacetimeDB 2.8.3 本地 standalone)**:持久表删列会被发布检查直接拒绝,
报 `Removing a column ... requires a manual migration`,仅传 `--delete-data=never --yes=migrate,break-clients`
不足以放行;`--delete-data=on-conflict` 则会清空整库。保留列的回退未采用,改用仓库既有的显式迁移路径:
`scripts/deploy-rust-remote.sh` 的 `run_conflict_migration_publish`(默认 `GENARRATIVE_SPACETIME_MIGRATE_ON_CONFLICT=true`)
会 导出旧库 → 清库发布新 wasm → 回灌迁移 JSON,因此不需要新增独立迁移脚本。
旧迁移包缺少新增列的导入兼容已在 `server-rs/crates/spacetime-module/src/migration.rs` 的
`normalize_migration_row` 补齐(`profile_membership` 回填 `plan` / 期数默认值;`profile_recharge_order`
回填 14 个 `membership_*` 快照默认值),并由同名单元测试守护。删列本身仍受本分支的
`SPACETIME_SCHEMA_GUARD_ALLOW_BREAKING=1` schema 门禁确认。
### 2.8 会员侧遗留清理清单
实施时**删除**(不是废弃),并同步修掉引用它们的测试: