会员档位目录种子改由模块初始化播种
新增 init 生命周期 reducer,数据库首次创建时把 profile_membership_plan 整表播种 membership_plan_row 与 membership_plan_records 去掉懒播种,只读路径不再写库 ensure_default_profile_recharge_product_config 不再顺带初始化会员目录 存量数据库此前已由懒播种写入目录行,新建数据库由 init reducer 播种
This commit is contained in:
@@ -8812,8 +8812,16 @@ fn ensure_default_profile_membership_plan(ctx: &ReducerContext) {
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_default_profile_recharge_product_config(ctx: &ReducerContext) {
|
||||
/// 模块初始化生命周期:只在数据库首次创建时把会员档位目录整表播种。
|
||||
///
|
||||
/// 迁移目的:报价 / 充值中心 / 后台查询等只读入口不再调用 `ensure_default_profile_membership_plan`
|
||||
/// 写库;存量数据库此前已由懒播种写入了目录行,新建数据库则由本 reducer 播种。
|
||||
#[spacetimedb::reducer(init)]
|
||||
pub fn init_profile_membership_plan_catalog(ctx: &ReducerContext) {
|
||||
ensure_default_profile_membership_plan(ctx);
|
||||
}
|
||||
|
||||
fn ensure_default_profile_recharge_product_config(ctx: &ReducerContext) {
|
||||
if ctx.db.profile_recharge_product_config().count() > 0 {
|
||||
migrate_legacy_default_profile_recharge_product_config(ctx);
|
||||
return;
|
||||
@@ -9146,7 +9154,6 @@ fn membership_plan_row(
|
||||
ctx: &ReducerContext,
|
||||
plan: RuntimeProfileMembershipPlan,
|
||||
) -> Option<ProfileMembershipPlan> {
|
||||
ensure_default_profile_membership_plan(ctx);
|
||||
ctx.db.profile_membership_plan().plan().find(&plan)
|
||||
}
|
||||
|
||||
@@ -9186,9 +9193,8 @@ fn membership_plan_snapshot(
|
||||
})
|
||||
}
|
||||
|
||||
/// 充值中心与后台共用的目录行读取,按 `rank` 升序。
|
||||
/// 充值中心与后台共用的目录行读取,按 `rank` 升序;只读,不再触发表为空时的懒播种。
|
||||
fn membership_plan_records(ctx: &ReducerContext) -> Vec<RuntimeProfileMembershipPlanRecord> {
|
||||
ensure_default_profile_membership_plan(ctx);
|
||||
let mut rows = ctx.db.profile_membership_plan().iter().collect::<Vec<_>>();
|
||||
rows.sort_by(|left, right| {
|
||||
left.rank
|
||||
|
||||
Reference in New Issue
Block a user