|
@@ -2152,9 +2152,6 @@ log.info("已添加template_id列到tasks表");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 关系类型表添加 default_role 列(角色模板)
|
|
|
|
|
- ensureColumn("relationship_types", "default_role", "VARCHAR(20) DEFAULT NULL COMMENT '默认角色模板: parent/child'");
|
|
|
|
|
-
|
|
|
|
|
// 家庭成员表添加 role_override 列(替换旧 capability_role)
|
|
// 家庭成员表添加 role_override 列(替换旧 capability_role)
|
|
|
ensureColumn("family_members", "role_override", "VARCHAR(20) DEFAULT 'auto' COMMENT '角色覆盖: auto/parent/child/elderly'");
|
|
ensureColumn("family_members", "role_override", "VARCHAR(20) DEFAULT 'auto' COMMENT '角色覆盖: auto/parent/child/elderly'");
|
|
|
try {
|
|
try {
|
|
@@ -2860,34 +2857,6 @@ log.info("已添加template_id列到tasks表");
|
|
|
log.warn("创建member_discount_configs表失败: {}", e.getMessage());
|
|
log.warn("创建member_discount_configs表失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- Integer hasCap = jdbcTemplate.queryForObject(
|
|
|
|
|
- "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'relationship_types' AND COLUMN_NAME = 'capability_role'",
|
|
|
|
|
- Integer.class);
|
|
|
|
|
- Integer hasDefault = jdbcTemplate.queryForObject(
|
|
|
|
|
- "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'relationship_types' AND COLUMN_NAME = 'default_role'",
|
|
|
|
|
- Integer.class);
|
|
|
|
|
- if (hasCap != null && hasCap == 0) {
|
|
|
|
|
- if (hasDefault != null && hasDefault > 0) {
|
|
|
|
|
- jdbcTemplate.execute("ALTER TABLE relationship_types CHANGE COLUMN default_role capability_role VARCHAR(20) NOT NULL COMMENT '能力角色: parent/child'");
|
|
|
|
|
- log.info("已将relationship_types.default_role重命名为capability_role");
|
|
|
|
|
- } else {
|
|
|
|
|
- jdbcTemplate.execute("ALTER TABLE relationship_types ADD COLUMN capability_role VARCHAR(20) NOT NULL DEFAULT 'parent' COMMENT '能力角色: parent/child' AFTER type_name");
|
|
|
|
|
- log.info("已添加capability_role列到relationship_types表");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.warn("relationship_types capability_role 迁移失败: {}", e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 确保capability_role有默认值(生产库该列NOT NULL无默认值,导致INSERT时Field doesn't have a default value错误)
|
|
|
|
|
- try {
|
|
|
|
|
- jdbcTemplate.execute("ALTER TABLE relationship_types MODIFY COLUMN capability_role VARCHAR(20) NOT NULL DEFAULT 'parent' COMMENT '能力角色: parent/child'");
|
|
|
|
|
- log.info("已修改relationship_types.capability_role添加默认值'parent'");
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.warn("修改relationship_types.capability_role默认值失败: {}", e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// ==================== 食材推荐指数 Phase: food_recommend_idx / food_recommend_idx_log ====================
|
|
// ==================== 食材推荐指数 Phase: food_recommend_idx / food_recommend_idx_log ====================
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `food_recommend_idx` (" +
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `food_recommend_idx` (" +
|
|
@@ -5426,12 +5395,7 @@ try {
|
|
|
log.info("已创建social_circle_member表");
|
|
log.info("已创建social_circle_member表");
|
|
|
} catch (Exception e) { /* 表已存在忽略 */ }
|
|
} catch (Exception e) { /* 表已存在忽略 */ }
|
|
|
|
|
|
|
|
- // 迁移89: relationship_types表添加分类和血亲字段
|
|
|
|
|
- ensureColumn("relationship_types", "category", "VARCHAR(50) DEFAULT 'social' COMMENT '关系分类: blood血亲/marriage姻亲/social社会关系'");
|
|
|
|
|
- ensureColumn("relationship_types", "is_blood_relation", "TINYINT DEFAULT 0 COMMENT '是否血亲关系: 1是0否'");
|
|
|
|
|
- ensureColumn("relationship_types", "is_immediate_family", "TINYINT DEFAULT 0 COMMENT '是否直系亲属: 1是0否'");
|
|
|
|
|
-
|
|
|
|
|
- // 迁移96: 创建活动订单评价表
|
|
|
|
|
|
|
+ // 迁移96: 创建活动订单评价表
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS review_orders (" +
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS review_orders (" +
|
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
@@ -7006,13 +6970,7 @@ private void runMigration100() {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
// 列已不存在,忽略
|
|
// 列已不存在,忽略
|
|
|
}
|
|
}
|
|
|
- try {
|
|
|
|
|
- jdbcTemplate.execute("DROP TABLE IF EXISTS relationship_types");
|
|
|
|
|
- log.info("已删除relationship_types表");
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- // 表已不存在,忽略
|
|
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
// 迁移101: product_skus表添加min_quantity列(商品规格最小购买数限制)
|
|
// 迁移101: product_skus表添加min_quantity列(商品规格最小购买数限制)
|
|
|
private void runMigration101() {
|
|
private void runMigration101() {
|
|
@@ -7748,5 +7706,21 @@ private void runMigration100() {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.warn("回填families.creator_id(任一成员)失败: {}", e.getMessage());
|
|
log.warn("回填families.creator_id(任一成员)失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移168: 修复文章表 null status 为 'draft'(旧版新建文章未设默认值导致无法编辑)
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("UPDATE articles SET status = 'draft' WHERE status IS NULL");
|
|
|
|
|
+ log.info("已修复articles表中status为null的记录为draft");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("修复articles表null status失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移169: 清理已废弃的 relationship_types 表(schema.sql 已移除,迁移代码中 ALTER 语句已清理)
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("DROP TABLE IF EXISTS relationship_types");
|
|
|
|
|
+ log.info("已清理废弃的relationship_types表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("清理relationship_types表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|