use of liquibase.change.AddColumnConfig in project liquibase by liquibase.
the class MissingIndexChangeGenerator method fixMissing.
@Override
public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
Index index = (Index) missingObject;
if (comparisonDatabase instanceof MSSQLDatabase) {
PrimaryKey primaryKey = index.getTable().getPrimaryKey();
if (primaryKey != null && DatabaseObjectComparatorFactory.getInstance().isSameObject(missingObject, primaryKey.getBackingIndex(), control.getSchemaComparisons(), referenceDatabase)) {
//will be handled by the PK
return new Change[0];
}
}
CreateIndexChange change = createCreateIndexChange();
change.setTableName(index.getTable().getName());
if (control.getIncludeTablespace()) {
change.setTablespace(index.getTablespace());
}
if (control.getIncludeCatalog()) {
change.setCatalogName(index.getTable().getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(index.getTable().getSchema().getName());
}
change.setIndexName(index.getName());
change.setUnique(index.isUnique() != null && index.isUnique() ? Boolean.TRUE : null);
change.setAssociatedWith(index.getAssociatedWithAsString());
change.setClustered(index.getClustered() != null && index.getClustered() ? Boolean.TRUE : null);
for (Column column : index.getColumns()) {
change.addColumn(new AddColumnConfig(column));
}
return new Change[] { change };
}
Aggregations