|
|
@@ -2685,6 +2685,26 @@ log.info("已添加template_id列到tasks表");
|
|
|
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());
|
|
|
+ }
|
|
|
+
|
|
|
log.info("数据库迁移完成");
|
|
|
|
|
|
// ==================== 健康维度 Phase 1: health_dimension_score / health_data_source_record / health_norm_reference ====================
|