AbstractDdlBuilder implements IDdlBuilder { public String alterTable(Table currentTable, Table desiredTable, IAlterDatabaseInterceptor... alterDatabaseInterceptors) { Database currentModel = new Database(); currentModel.addTable(currentTable); Database desiredModel = new Database(); desiredModel.addTable(desiredTable); return alterDatabase(currentModel, desiredModel, alterDatabaseInterceptors); } AbstractDdlBuilder(String databaseName); DefaultValueHelper getDefaultValueHelper(); String getIndent(); void setIndent(String indent); String getValueLocale(); void setValueLocale(String localeStr); String createTables(Database database, boolean dropTables); void createTables(Database database, boolean dropTables, StringBuilder ddl); String alterDatabase(Database currentModel, Database desiredModel,
            IAlterDatabaseInterceptor... alterDatabaseInterceptors); String alterTable(Table currentTable, Table desiredTable,
            IAlterDatabaseInterceptor... alterDatabaseInterceptors); void alterDatabase(Database currentModel, Database desiredModel, StringBuilder ddl,
            IAlterDatabaseInterceptor... alterDatabaseInterceptors); boolean isAlterDatabase(Database currentModel, Database desiredModel,
            IAlterDatabaseInterceptor... alterDatabaseInterceptors); List<IModelChange> getDetectedChanges(Database currentModel, Database desiredModel, IAlterDatabaseInterceptor... alterDatabaseInterceptors); Table getBackupTableFor(Table sourceTable); Table createBackupTableFor(Database model, Table sourceTable, StringBuilder ddl); void restoreTableFromBackup(Table backupTable, Table targetTable, LinkedHashMap<Column, Column> columnMap,
            StringBuilder ddl); void writeCopyDataStatement(Table sourceTable, Table targetTable, StringBuilder ddl); void writeCopyDataStatement(Table sourceTable, Table targetTable, LinkedHashMap<Column, Column> columnMap,
            StringBuilder ddl); LinkedHashMap<Column, Column> getCopyDataColumnMapping(Table sourceTable, Table targetTable); LinkedHashMap<Column, Column> getCopyDataColumnOrderedMapping(Table sourceTable, Table targetTable); String createTable(Table table); void createExternalForeignKeys(Database database, StringBuilder ddl); void createExternalForeignKeys(Database database, Table table, StringBuilder ddl); String dropTables(Database database); void dropTables(Database database, StringBuilder ddl); void dropTable(Database database, Table table, StringBuilder ddl); void dropExternalForeignKeys(Table table, StringBuilder ddl); String getInsertSql(Table table, Map<String, Object> columnValues, boolean genPlaceholders); String getUpdateSql(Table table, Map<String, Object> columnValues, boolean genPlaceholders); String getDeleteSql(Table table, Map<String, Object> pkValues, boolean genPlaceholders); String getSelectLastIdentityValues(Table table); String fixLastIdentityValues(Table table); void writeFixLastIdentityValues(Table table, StringBuilder ddl); String shortenName(String name, int desiredLength); String getTableName(String tableName); String getColumnTypeDdl(Table table, Column column); boolean areColumnSizesTheSame(Column sourceColumn, Column targetColumn); String getForeignKeyName(Table table, ForeignKey fk); String getConstraintName(String prefix, Table table, String secondPart, String suffix); String getIndexName(IIndex index); void writeExternalIndexDropStmt(Table table, IIndex index, StringBuilder ddl); boolean isScriptModeOn(); void setScriptModeOn(boolean scriptModeOn); boolean isSqlCommentsOn(); void setSqlCommentsOn(boolean sqlCommentsOn); boolean isDelimitedIdentifierModeOn(); void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn); DatabaseInfo getDatabaseInfo(); void setCaseSensitive(boolean caseSensitive); boolean isCaseSensitive();  }
@Test public void testAlterTableWithNewVarcharSizeForPlatformWithPlatformColumn() throws Exception { for (AbstractDdlBuilder ddlBuilder : ddlBuilders) { Table currentTable = new Table("Test", new Column("ID", true, Types.INTEGER, 50, 0), new Column("TXT", false, Types.VARCHAR, 50, 0)); currentTable.getColumnWithName("TXT").addPlatformColumn( new PlatformColumn(DatabaseNamesConstants.H2, "VARCHAR2", 50, 0, null)); Table desiredTable = new Table("Test", new Column("ID", true, Types.INTEGER, 50, 0), new Column("TXT", false, Types.VARCHAR, 255, 0)); String alterSql = ddlBuilder.alterTable(currentTable, desiredTable); assertTrue("Failed to generate an appropriate alter for the following platform: " + ddlBuilder.databaseName, alterSql.contains("255")); } }
@Test public void testAlterTableWithNewVarcharSizeForPlatformWithoutPlatformColumn() throws Exception { for (AbstractDdlBuilder ddlBuilder : ddlBuilders) { Table currentTable = new Table("Test", new Column("ID", true, Types.INTEGER, 50, 0), new Column("TXT", false, Types.VARCHAR, 50, 0)); Table desiredTable = new Table("Test", new Column("ID", true, Types.INTEGER, 50, 0), new Column("TXT", false, Types.VARCHAR, 255, 0)); String alterSql = ddlBuilder.alterTable(currentTable, desiredTable); assertTrue("Failed to generate an appropriate alter for the following platform: " + ddlBuilder.databaseName, alterSql.contains("255")); } }