{"record":{"id":"b5c79a67a56d684d","repo":"MyCATApache/Mycat-Server","slug":"schemaname-tablename-old-new-partition-colum","errorCode":null,"errorMessage":"{schemaName}:{tableName} old & new partition column is not same!","messagePattern":"(.+?):(.+?) old & new partition column is not same!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java","lineNumber":242,"sourceCode":"\t\t\tDBHostConfig[]  writeHosts = dh.getWriteHosts();\n\t\t\tDBHostConfig currentWriteHost;\n\t\t\tif(isAwaysUseMaster){\n\t\t\t\tcurrentWriteHost = writeHosts[0];\n\t\t\t}else{\n\t\t\t    //迁移数据发生在当前切换后的数据源\n\t\t\t\tcurrentWriteHost = writeHosts[Integer.valueOf(dnIndexProps.getProperty(dh.getName()))];\n\t\t\t}\n\t\t\tDataNode dn = new DataNode(name,currentWriteHost.getIp(), currentWriteHost.getPort(), currentWriteHost.getUser(), currentWriteHost.getPassword(), db, dbType,i++);\n\t\t\tdataNodes.add(dn);\n\t\t}\n\t\t\n\t\treturn dataNodes;\n\t}\n\t\n\t//校验前后路由规则是否一致\n\tprivate void checkRuleConfig(RuleConfig oldRC,RuleConfig newRC,String schemaName,String tableName){\n\t\tif(!oldRC.getColumn().equalsIgnoreCase(newRC.getColumn())){\n\t\t\tthrow new ConfigException(schemaName+\":\"+tableName+\" old & new partition column is not same!\");\n\t\t}\n\t\tAbstractPartitionAlgorithm oldAlg = oldRC.getRuleAlgorithm();\n\t\tAbstractPartitionAlgorithm newAlg = newRC.getRuleAlgorithm();\n\t\t//判断路由算法前后是否一致\n\t\tif(!oldAlg.getClass().isAssignableFrom(newAlg.getClass())){\n\t\t\tthrow new ConfigException(schemaName+\":\"+tableName+\" old & new rule Algorithm is not same!\");\n\t\t}\n\t}\n\t\n\tprivate Properties loadDnIndexProps() {\n\t\tProperties prop = new Properties();\n\t\tInputStream is = null;\n\t\ttry {\n\t\t\tis = ConfigComparer.class.getResourceAsStream(DN_INDEX_FILE);\n\t\t\tprop.load(is);\n\t\t} catch (Exception e) {\n\t\t\tthrow new ConfigException(\"please check file \\\"dnindex.properties\\\" \"+e.getMessage());\n\t\t} finally {","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java#L224-L260","documentation":"checkRuleConfig enforces that the sharding (partition) column stays the same between the old and new rule configurations. Data migration physically redistributes rows between data nodes; changing the partition column would make redistributed data inconsistent, so a ConfigException is thrown when the columns differ (case-insensitive compare).","triggerScenarios":"Running the migrator when the <rule><columns> value for a table differs between old and new rule.xml/schema.xml — e.g. changing sharding from user_id to order_id.","commonSituations":"Refactoring the sharding key during a migration; rule.xml edited for the new cluster pointing at a different column; copy-pasting rule config from another table.","solutions":["Make the <columns> value identical in the old and new rule configurations for this table.","If the sharding key genuinely must change, migrate data with another tool (e.g. dump/reload) instead of this data-migrator.","Verify rule.xml referenced by both configs before rerunning.","Check for case/whitespace differences in the column name."],"exampleFix":"// before: new rule.xml\n<columns>order_id</columns>\n// after (match old config)\n<columns>user_id</columns>","handlingStrategy":"validation","validationCode":"RuleConfig oldRC = oldTable.getRule();\nRuleConfig newRC = newTable.getRule();\nif (oldRC == null || newRC == null ||\n    !oldRC.getColumn().equalsIgnoreCase(newRC.getColumn())) {\n    throw new IllegalArgumentException(\"partition column changed for \" + tableName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    comparer.compare();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"partition column is not same\")) {\n        // revert <columns> in new rule.xml to match old config\n    }\n    throw e;\n}","preventionTips":["Freeze sharding column choices during a migration window","Diff rule.xml between old and new configs as a pre-migration step","Never repurpose rule functions with a different column in the new config"],"tags":["java","data-migration","sharding","configuration"],"backgroundTag":"conflicting-config-options","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}