分片键修改不更新

This commit is contained in:
张松
2025-01-03 15:21:06 +08:00
parent c49a165dd9
commit 3fd322b355
7 changed files with 32 additions and 34 deletions

View File

@@ -148,24 +148,24 @@ public class ShardingConfig {
for (String regionTable : regionTables) {
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
tableRuleConfig.setDatabaseShardingStrategyConfig(databaseShardingStrategyConfig);
// 设置区域表使用雪花算法生成主键
switch (regionTable){
case "orders":
tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "orders_id"));
break;
case "course_collect":
tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_collect_id"));
break;
case "course_user":
tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_user_id"));
break;
case "tb_user":
tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "user_id"));
break;
default:
tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "id"));
break;
}
// // 设置区域表使用雪花算法生成主键
// switch (regionTable){
// case "orders":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "orders_id"));
// break;
//// case "course_collect":
//// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_collect_id"));
//// break;
// case "course_user":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_user_id"));
// break;
// case "tb_user":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "user_id"));
// break;
// default:
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "id"));
// break;
// }
sets.add(tableRuleConfig);
}
@@ -254,4 +254,4 @@ public class ShardingConfig {
}
return tableNames.toString();
}
}
}