@Override
public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
PrimaryKey pk = (PrimaryKey) missingObject;
AddPrimaryKeyChange change = new AddPrimaryKeyChange();
change.setTableName(pk.getTable().getName());
if (control.getIncludeCatalog()) {
change.setCatalogName(pk.getTable().getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(pk.getTable().getSchema().getName());
}
change.setConstraintName(pk.getName());
change.setColumnNames(pk.getColumnNames());
if (control.getIncludeTablespace()) {
change.setTablespace(pk.getTablespace());
}
if (referenceDatabase instanceof MSSQLDatabase && pk.getBackingIndex() != null && pk.getBackingIndex().getClustered() != null && !pk.getBackingIndex().getClustered()) {
change.setClustered(false);
}
control.setAlreadyHandledMissing(pk.getBackingIndex());
return new Change[] { change };