|
|
@@ -3394,6 +3394,9 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
|
|
|
log.warn("迁移504: adjust_ref_id 加列失败(幂等容忍): {}", e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ // 迁移505: unlock_gates 去重(每gate_type留最小id) + 加唯一键,防止一次通关发多次奖励
|
|
|
+ migrateUnlockGatesDedup();
|
|
|
+
|
|
|
// 迁移406: activity_poster_templates 增加 layout_config 列(海报模板元素位置/样式可配置,需求:活动详情海报预览重设计)
|
|
|
addActivityPosterTemplateLayoutConfigColumn();
|
|
|
|
|
|
@@ -15209,6 +15212,29 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 迁移505: unlock_gates 去重 + 唯一键。
|
|
|
+ * 历史 bug:8月12日关卡被播种4次,每 gate_type 4 条,refreshFamilyGates 逐条发奖导致一次通关发4次。
|
|
|
+ * 幂等:先删除每 gate_type 非最小 id 的重复行,再加 uk_gate_type 唯一键。
|
|
|
+ */
|
|
|
+ private void migrateUnlockGatesDedup() {
|
|
|
+ try {
|
|
|
+ int deleted = jdbcTemplate.update(
|
|
|
+ "DELETE FROM unlock_gates WHERE id NOT IN "
|
|
|
+ + "(SELECT min_id FROM (SELECT MIN(id) AS min_id FROM unlock_gates GROUP BY gate_type) t)");
|
|
|
+ if (deleted > 0) log.info("迁移505: 清理 unlock_gates 重复行 {} 条", deleted);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移505: unlock_gates 去重失败(幂等容忍): {}", e.getMessage());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("ALTER TABLE unlock_gates ADD UNIQUE KEY uk_gate_type (gate_type)");
|
|
|
+ log.info("迁移505: unlock_gates.uk_gate_type 唯一键已添加");
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 唯一键已存在时忽略
|
|
|
+ log.info("迁移505: uk_gate_type 已存在或添加跳过: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void alterSurveyRecordTemplateIdNullable() {
|
|
|
try {
|
|
|
jdbcTemplate.execute("ALTER TABLE survey_records MODIFY COLUMN template_id BIGINT NULL "
|