@Test(expected = IllegalStateException.class) public void testExpandForDroppingIdentityColumn() { DropColumn operation = SchemaOperations.dropColumn("users", "id"); changelog.addChangeSet("Michael de Jong", "Dropped 'id' column from 'users' table.", operation); migrator.migrate(catalog, refLog, changelog.getLastAdded(), operation); }
@Override public void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); String refId = tableRef.getRefId(); tableRef.dropColumn(operation.getColumnName()); Table table = catalog.getTable(refId); table.removeColumn(operation.getColumnName()); List<Index> indexes = Lists.newArrayList(table.getIndexes()); for (Index index : indexes) { table.removeIndex(index.getColumns()); } }
DropColumnMigrator implements SchemaOperationMigrator<DropColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); String refId = tableRef.getRefId(); tableRef.dropColumn(operation.getColumnName()); Table table = catalog.getTable(refId); table.removeColumn(operation.getColumnName()); List<Index> indexes = Lists.newArrayList(table.getIndexes()); for (Index index : indexes) { table.removeIndex(index.getColumns()); } } }
DropColumnMigrator implements SchemaOperationMigrator<DropColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); String refId = tableRef.getRefId(); tableRef.dropColumn(operation.getColumnName()); Table table = catalog.getTable(refId); table.removeColumn(operation.getColumnName()); List<Index> indexes = Lists.newArrayList(table.getIndexes()); for (Index index : indexes) { table.removeIndex(index.getColumns()); } }  }
DropColumnMigrator implements SchemaOperationMigrator<DropColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); String refId = tableRef.getRefId(); tableRef.dropColumn(operation.getColumnName()); Table table = catalog.getTable(refId); table.removeColumn(operation.getColumnName()); List<Index> indexes = Lists.newArrayList(table.getIndexes()); for (Index index : indexes) { table.removeIndex(index.getColumns()); } }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation); }
DropColumnMigrator implements SchemaOperationMigrator<DropColumn> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation) { String tableName = operation.getTableName(); TransitiveTableMirrorer.mirror(catalog, refLog, version, tableName); TableRef tableRef = refLog.getTableRef(version, tableName); String refId = tableRef.getRefId(); tableRef.dropColumn(operation.getColumnName()); Table table = catalog.getTable(refId); table.removeColumn(operation.getColumnName()); List<Index> indexes = Lists.newArrayList(table.getIndexes()); for (Index index : indexes) { table.removeIndex(index.getColumns()); } }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, DropColumn operation);  }