{"record":{"id":"cab0c92be6ef4e8a","repo":"MyCATApache/Mycat-Server","slug":"newschema-schemaname-is-not-exists","errorCode":null,"errorMessage":"newSchema:{schemaName} is not exists!","messagePattern":"newSchema:(.+?) is not exists!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java","lineNumber":136,"sourceCode":"\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();\n\t\t\tif(!oldSet.equals(newSet)){\n\t\t\t\tthrow new ConfigException(\"new & old table config is not equal!\");\n\t\t\t}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java#L118-L154","documentation":"loadMigratorTables also validates the schema name against the NEW schema configuration (schema.xml after migration). If the schema exists in the old config but not in the new one, a ConfigException is thrown. Migration requires the schema to exist in both configurations so tables can be compared and moved.","triggerScenarios":"tablesFile.properties lists a schema present in the old schema.xml but missing from the new schema.xml — typically the schema was dropped or renamed in the target configuration.","commonSituations":"Operator removed the schema from the new schema.xml while planning data redistribution; renamed schema during migration but forgot to update tablesFile.properties; typo when writing the new schema.xml.","solutions":["Add the missing schema definition to the new schema.xml (with its tables and data nodes).","Or update tablesFile.properties to use the schema's new name as defined in the new schema.xml.","Confirm both schema.xml versions define the same schema names before rerunning the migrator."],"exampleFix":"// before: new schema.xml lacks the schema\n<schema name=\"ordersdb\" ...> <!-- missing -->\n// after\n<schema name=\"ordersdb\" checkSQLschema=\"false\" dataNode=\"dn1\"> ... </schema>","handlingStrategy":"validation","validationCode":"Set<String> newSchemaNames = newSchemas.keySet().stream()\n    .map(String::toLowerCase).collect(Collectors.toSet());\nfor (String schema : prop.stringPropertyNames()) {\n    if (!newSchemaNames.contains(schema.toLowerCase().trim())) {\n        throw new IllegalArgumentException(\"schema missing from NEW config: \" + schema);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    comparer.compare();\n} catch (ConfigException e) {\n    if (e.getMessage().startsWith(\"newSchema:\")) {\n        // add the schema to new schema.xml or rename the entry in tablesFile.properties\n    }\n    throw e;\n}","preventionTips":["Diff old vs new schema.xml schema names before every migration","Never drop a schema from the new config while it still has rows to migrate","Automate a pre-flight check comparing schema sets in both configs"],"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"}