private String getModifyColumnString(DaColumn col) { return this.getColumnString(col, false); }
private void generateDiffsToTable(DaTable table, DaTable idealTable, File outputFile) { MutableCollection<CompareBreak> compareBreaks = dbMetadataComparisonUtil.compareTables(table, idealTable); this.handleBreaks(table, idealTable, compareBreaks, outputFile); /* generate merges against the ideal table (if possible - change may be incompatible) */ }
public static void main(String[] argsArr) { DbFileMergerArgs args = new ArgsParser().parse(argsArr, new DbFileMergerArgs()); new TableSyncher().execute(args); }
if (objectBreak.getObject() instanceof DaColumn) { DaColumn col = (DaColumn) objectBreak.getObject(); this.printSql(ps, "addCol" + col.getName(), this.getAddColumnString(col)); } else if (objectBreak.getObject() instanceof DaTable) { LOG.debug("Ignoring this break [{}], relying on AquaReveng to do this", objectBreak.getObject()); DaIndex index = (DaIndex) objectBreak.getObject(); if (table.getPrimaryKey() == null || !DaIndex.TO_COLUMNS.valueOf(table.getPrimaryKey()).equals(DaIndex.TO_COLUMNS.valueOf(index))) { this.printSql(ps, "addIndex" + index.getName(), this.getIndexSql(index)); } else { System.out.println("Warning - a case where one side has a unique index that is represented as a pk"); this.printSql(ps, "unhandled", "Unhandled Object Break: " + objectBreak.getObject().getClass() + ":" + objectBreak); DaColumn col = (DaColumn) fieldBreak.getLeft(); if (fieldBreak.getFieldName().equals("nullable")) { this.printSql(ps , "modifyNullable_" + col.getName() , "-- if the difference is in the nullable value, then set it to nullable for compatibility across instances\n" + "ALTER TABLE " + col.getParent().getName() + " MODIFY " + col.getName() + " NULL"); } else if (fieldBreak.getFieldName().equals("width")) { this.printSql(ps , "modifyWidth_" + col.getName() , "-- if the difference is in the width value, then set it to the max value\n" + "ALTER TABLE " + col.getParent().getName() + " MODIFY " + col.getName() + " " + col.getColumnDataType()); } else if (fieldBreak.getFieldName().equals("default")) { this.printSql(ps , "modifyDefault_" + col.getName() , "-- if the difference is in the default value, then change it\n"
private void syncSchemaTables(DbPlatform dbPlatform, RichIterable<TableSyncSide> syncSides, File outputDir) { for (TableSyncSide syncSide : syncSides) { syncSide.enrichTables(dbPlatform); } RichIterable<DaTable> idealTables = this.createIdealTables(syncSides); MapIterable<String, DaTable> idealTablesMap = idealTables.groupByUniqueKey(DaNamedObject.TO_NAME); System.out.println("Starting the alters"); for (TableSyncSide syncSide : syncSides) { for (DaTable table : syncSide.getTables()) { File outputFile = new File(new File(outputDir, syncSide.getSchema().getPhysicalName()), table.getName() + ".sql"); this.generateDiffsToTable(table, idealTablesMap.get(table.getName()), outputFile); } } }
@Test public void testSyncSchemaTables() throws Exception { TableSyncher.main(("-dbMergeConfigFile " + "src/test/resources/scenariotests/reveng-merge/merge-config-with-correction.txt " + "-outputDir ./target/merge/unittest").split(" ")); } }
@Override public void value(String[] argSubset) { DbFileMergerArgs tableMergeArgsObj = new ArgsParser().parse(argSubset, new DbFileMergerArgs()); new TableSyncher().execute(tableMergeArgsObj); } });
if (objectBreak.getObject() instanceof DaColumn) { DaColumn col = (DaColumn) objectBreak.getObject(); this.printSql(ps, "addCol" + col.getName(), this.getAddColumnString(col)); } else if (objectBreak.getObject() instanceof DaTable) { LOG.debug("Ignoring this break [{}], relying on AquaReveng to do this", objectBreak.getObject()); DaIndex index = (DaIndex) objectBreak.getObject(); if (table.getPrimaryKey() == null || !DaIndex.TO_COLUMNS.valueOf(table.getPrimaryKey()).equals(DaIndex.TO_COLUMNS.valueOf(index))) { this.printSql(ps, "addIndex" + index.getName(), this.getIndexSql(index)); } else { System.out.println("Warning - a case where one side has a unique index that is represented as a pk"); this.printSql(ps, "unhandled", "Unhandled Object Break: " + objectBreak.getObject().getClass() + ":" + objectBreak); DaColumn col = (DaColumn) fieldBreak.getLeft(); if (fieldBreak.getFieldName().equals("nullable")) { this.printSql(ps , "modifyNullable_" + col.getName() , "-- if the difference is in the nullable value, then set it to nullable for compatibility across instances\n" + "ALTER TABLE " + col.getParent().getName() + " MODIFY " + col.getName() + " NULL"); } else if (fieldBreak.getFieldName().equals("width")) { this.printSql(ps , "modifyWidth_" + col.getName() , "-- if the difference is in the width value, then set it to the max value\n" + "ALTER TABLE " + col.getParent().getName() + " MODIFY " + col.getName() + " " + col.getColumnDataType()); } else if (fieldBreak.getFieldName().equals("default")) { this.printSql(ps , "modifyDefault_" + col.getName() , "-- if the difference is in the default value, then change it\n"
private void syncSchemaTables(DbPlatform dbPlatform, RichIterable<TableSyncSide> syncSides, File outputDir) { for (TableSyncSide syncSide : syncSides) { syncSide.enrichTables(dbPlatform); } RichIterable<DaTable> idealTables = this.createIdealTables(syncSides); MapIterable<String, DaTable> idealTablesMap = idealTables.groupByUniqueKey(DaNamedObject.TO_NAME); System.out.println("Starting the alters"); for (TableSyncSide syncSide : syncSides) { for (DaTable table : syncSide.getTables()) { File outputFile = new File(new File(outputDir, syncSide.getSchema().getPhysicalName()), table.getName() + ".sql"); this.generateDiffsToTable(table, idealTablesMap.get(table.getName()), outputFile); } } }
public static void main(String[] argsArr) { DbFileMergerArgs args = new ArgsParser().parse(argsArr, new DbFileMergerArgs()); new TableSyncher().execute(args); }
private String getModifyColumnString(DaColumn col) { return this.getColumnString(col, false); }
private void generateDiffsToTable(DaTable table, DaTable idealTable, File outputFile) { MutableCollection<CompareBreak> compareBreaks = dbMetadataComparisonUtil.compareTables(table, idealTable); this.handleBreaks(table, idealTable, compareBreaks, outputFile); /* generate merges against the ideal table (if possible - change may be incompatible) */ }
private String getAddColumnString(DaColumn col) { return this.getColumnString(col, true); }
private String getAddColumnString(DaColumn col) { return this.getColumnString(col, true); }