return null;
}
@Override
public Change[] fixChanged(DatabaseObject changedObject, ObjectDifferences differences, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
ForeignKey fk = (ForeignKey) changedObject;
StringUtils.StringUtilsFormatter formatter = new StringUtils.StringUtilsFormatter<Column>() {
@Override
public String toString(Column obj) {
return obj.toString(false);
}
};
DropForeignKeyConstraintChange dropFkChange = new DropForeignKeyConstraintChange();
dropFkChange.setConstraintName(fk.getName());
dropFkChange.setBaseTableName(fk.getForeignKeyTable().getName());
AddForeignKeyConstraintChange addFkChange = new AddForeignKeyConstraintChange();
addFkChange.setConstraintName(fk.getName());
addFkChange.setBaseTableName(fk.getForeignKeyTable().getName());
addFkChange.setBaseColumnNames(StringUtils.join(fk.getForeignKeyColumns(), ",", formatter));
addFkChange.setReferencedTableName(fk.getPrimaryKeyTable().getName());
addFkChange.setReferencedColumnNames(StringUtils.join(fk.getPrimaryKeyColumns(), ",", formatter));
if (control.getIncludeCatalog()) {
dropFkChange.setBaseTableCatalogName(fk.getForeignKeyTable().getSchema().getCatalogName());
addFkChange.setBaseTableCatalogName(fk.getForeignKeyTable().getSchema().getCatalogName());
addFkChange.setReferencedTableCatalogName(fk.getPrimaryKeyTable().getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
dropFkChange.setBaseTableSchemaName(fk.getForeignKeyTable().getSchema().getName());
addFkChange.setBaseTableSchemaName(fk.getForeignKeyTable().getSchema().getName());
addFkChange.setReferencedTableSchemaName(fk.getPrimaryKeyTable().getSchema().getName());
}
if (fk.getBackingIndex() != null) {
control.setAlreadyHandledChanged(fk.getBackingIndex());
}
return new Change[] { dropFkChange, addFkChange };
}