{"record":{"id":"4130d24539293d5a","repo":"MyCATApache/Mycat-Server","slug":"oldschema-schemaname-is-not-exists","errorCode":null,"errorMessage":"oldSchema:{schemaName} is not exists!","messagePattern":"oldSchema:(.+?) is not exists!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java","lineNumber":133,"sourceCode":"\t\t\tString tables = entry.getValue().toString();\n\t\t\tloadMigratorTables(schemaName,getTables(tables));\n\t\t}\n\t}\n\t\n\tprivate String[] getTables(String tables){\n\t\tif(tables.equalsIgnoreCase(\"all\") || tables.isEmpty()){\n\t\t\treturn new String[]{};\n\t\t}else{\n\t\t\treturn tables.split(\",\");\n\t\t}\n\t}\n\t\n\t/*\n\t * 加载迁移表信息，tables大小为0表示迁移schema下所有表\n\t */\n\tprivate void loadMigratorTables(String schemaName,String[] tables){\n\t\tif(!DataMigratorUtil.isKeyExistIgnoreCase(oldSchemas, schemaName)){\n\t\t\tthrow new ConfigException(\"oldSchema:\"+schemaName+\" is not exists!\");\n\t\t}\n\t\tif(!DataMigratorUtil.isKeyExistIgnoreCase(newSchemas,schemaName)){\n\t\t\tthrow new ConfigException(\"newSchema:\"+schemaName+\" is not exists!\");\n\t\t}\n\t\tMap<String, TableConfig> oldTables =  DataMigratorUtil.getValueIgnoreCase(oldSchemas, schemaName).getTables();\n\t\tMap<String, TableConfig> newTables = DataMigratorUtil.getValueIgnoreCase(newSchemas, schemaName).getTables();\n\t\tif(tables.length>0){\n\t\t\t//指定schema下的表进行迁移\n\t\t\tfor(int i =0;i<tables.length;i++){\n\t\t\t\tTableConfig oldTable =  DataMigratorUtil.getValueIgnoreCase(oldTables,tables[i]);\n\t\t\t\tTableConfig newTable = DataMigratorUtil.getValueIgnoreCase(newTables,tables[i]);\n\t\t\t\tloadMigratorTable(oldTable, newTable,schemaName,tables[i]);\n\t\t\t}\n\t\t}else{\n\t\t\t//迁移schema下所有的表\n\t\t\t//校验新旧schema中的table配置是否一致\n\t\t\tSet<String> oldSet = oldTables.keySet();\n\t\t\tSet<String> newSet = newTables.keySet();","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java#L115-L151","documentation":"loadMigratorTables validates that every schema listed in tablesFile.properties exists in the OLD schema configuration (schema.xml before migration). If the schema name is absent (case-insensitive check), migration cannot proceed and a ConfigException is thrown. This guards against migrating tables from a schema that never existed in the source cluster.","triggerScenarios":"tablesFile.properties contains a key (schema name) that does not match any schema defined in the old schema.xml — due to typos, renamed schemas, case mismatches beyond the ignore-case handling, or a stale properties file.","commonSituations":"Operator edits tablesFile.properties and misspells a schema; schema was renamed/dropped in the old config; copy-pasting schema names with extra whitespace.","solutions":["Open tablesFile.properties and check the offending key; correct the schema name to exactly match a schema in the old schema.xml.","Compare against the schemas loaded from the old config and remove entries for schemas that no longer exist.","Trim whitespace around the key in the properties file.","Regenerate tablesFile.properties from the actual old configuration instead of hand-editing."],"exampleFix":"// before: tablesFile.properties\nORDERS_DB:table1,table2\n// after (schema exists in old schema.xml as ordersdb)\nordersdb:table1,table2","handlingStrategy":"validation","validationCode":"Set<String> oldSchemaNames = oldSchemas.keySet().stream()\n    .map(String::toLowerCase).collect(Collectors.toSet());\nfor (String schema : prop.stringPropertyNames()) {\n    if (!oldSchemaNames.contains(schema.toLowerCase().trim())) {\n        throw new IllegalArgumentException(\"schema not in old config: \" + schema);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    comparer.compare();\n} catch (ConfigException e) {\n    if (e.getMessage().startsWith(\"oldSchema:\")) {\n        // fix tablesFile.properties schema key against old schema.xml\n    }\n    throw e;\n}","preventionTips":["Generate tablesFile.properties keys directly from old schema.xml rather than typing them","Trim whitespace in properties keys","Grep the old schema.xml for the schema name before running migration","Keep old and new configs in version control side by side"],"tags":["java","configuration","data-migration","schema"],"backgroundTag":"entity-not-found","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"}