@Test public void testExpandForRenamingTable() { RenameTable operation = SchemaOperations.renameTable("users", "customers"); changelog.addChangeSet("Michael de Jong", "Renaming 'users' table to 'customers'.", operation); migrator.migrate(catalog, refLog, changelog.getLastAdded(), operation); String refId = refLog.getTableRef(changelog.getLastAdded(), "customers").getRefId(); Table ghostTable = catalog.getTable(refId); Table expectedGhostTable = new Table(refId) .addColumn(new Column("id", integer(), IDENTITY, NOT_NULL, AUTO_INCREMENT)) .addColumn(new Column("name", varchar(255), NOT_NULL)); assertEquals(expectedGhostTable, ghostTable); assertEquals("users", refLog.getTableRef(changelog.getLastAdded(), "customers").getRefId()); assertFalse(refLog.getTableRefs(changelog.getLastAdded()).stream() .anyMatch(tableRef -> tableRef.getName().equals("users"))); }
@Override public void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation) { refLog.fork(version); TableRef tableRef = refLog.getTableRef(version, operation.getTableName()); TableRef ghost = tableRef.ghost(tableRef.getRefId(), version); ghost.rename(operation.getNewTableName()); }
RenameTableMigrator implements SchemaOperationMigrator<RenameTable> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation) { refLog.fork(version); TableRef tableRef = refLog.getTableRef(version, operation.getTableName()); TableRef ghost = tableRef.ghost(tableRef.getRefId(), version); ghost.rename(operation.getNewTableName()); } }
RenameTableMigrator implements SchemaOperationMigrator<RenameTable> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation) { refLog.fork(version); TableRef tableRef = refLog.getTableRef(version, operation.getTableName()); TableRef ghost = tableRef.ghost(tableRef.getRefId(), version); ghost.rename(operation.getNewTableName()); }  }
RenameTableMigrator implements SchemaOperationMigrator<RenameTable> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation) { refLog.fork(version); TableRef tableRef = refLog.getTableRef(version, operation.getTableName()); TableRef ghost = tableRef.ghost(tableRef.getRefId(), version); ghost.rename(operation.getNewTableName()); }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation); }
RenameTableMigrator implements SchemaOperationMigrator<RenameTable> { @Override public void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation) { refLog.fork(version); TableRef tableRef = refLog.getTableRef(version, operation.getTableName()); TableRef ghost = tableRef.ghost(tableRef.getRefId(), version); ghost.rename(operation.getNewTableName()); }  @Override void migrate(Catalog catalog, RefLog refLog, Version version, RenameTable operation);  }