@Test public void testExpandForAddingMultipleColumns() { AddColumn operation1 = SchemaOperations.addColumn("users", "date_of_birth", date(), "NULL"); changelog.addChangeSet("Michael de Jong", "Added 'date_of_birth' column to 'users' table.", operation1); migrator.migrate(catalog, refLog, changelog.getLastAdded(), operation1); AddColumn operation2 = SchemaOperations.addColumn("users", "activated", bool(), "TRUE"); changelog.addChangeSet("Michael de Jong", "Added 'activated' column to 'users' table.", operation2); migrator.migrate(catalog, refLog, changelog.getLastAdded(), operation2); Table originalTable = catalog.getTable("users"); Table ghostTable = getGhostTable(originalTable); Table expectedGhostTable = new Table(ghostTable.getName()) .addColumn(new Column("id", integer(), IDENTITY, NOT_NULL, AUTO_INCREMENT)) .addColumn(new Column("name", varchar(255), NOT_NULL)) .addColumn(new Column("date_of_birth", date(), "NULL")) .addColumn(new Column("activated", bool(), "TRUE")); assertEquals(3, catalog.getTables().size()); assertEquals(expectedGhostTable, ghostTable); }
@Override public void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); Table table = catalog.getTable(tableRef.getRefId()); table.addColumn(operation.getColumnDefinition().createColumn()); tableRef.addColumn(new ColumnRef(operation.getColumnDefinition().getName())); }
AddColumnMigrator implements SchemaOperationMigrator<AddColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); Table table = catalog.getTable(tableRef.getRefId()); table.addColumn(operation.getColumnDefinition().createColumn()); tableRef.addColumn(new ColumnRef(operation.getColumnDefinition().getName())); } }
AddColumnMigrator implements SchemaOperationMigrator<AddColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); Table table = catalog.getTable(tableRef.getRefId()); table.addColumn(operation.getColumnDefinition().createColumn()); tableRef.addColumn(new ColumnRef(operation.getColumnDefinition().getName())); }  }
AddColumnMigrator implements SchemaOperationMigrator<AddColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); Table table = catalog.getTable(tableRef.getRefId()); table.addColumn(operation.getColumnDefinition().createColumn()); tableRef.addColumn(new ColumnRef(operation.getColumnDefinition().getName())); }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation); }
AddColumnMigrator implements SchemaOperationMigrator<AddColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); Table table = catalog.getTable(tableRef.getRefId()); table.addColumn(operation.getColumnDefinition().createColumn()); tableRef.addColumn(new ColumnRef(operation.getColumnDefinition().getName())); }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, AddColumn operation);  }