use of liquibase.change.Change in project liquibase by liquibase.
the class UnexpectedPrimaryKeyChangeGenerator method fixUnexpected.
@Override
public Change[] fixUnexpected(DatabaseObject unexpectedObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
// if (!diffResult.getObjectDiff(Table.class).getUnexpected().contains(pk.getTable())) {
PrimaryKey pk = (PrimaryKey) unexpectedObject;
DropPrimaryKeyChange change = new DropPrimaryKeyChange();
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());
Index backingIndex = pk.getBackingIndex();
control.setAlreadyHandledUnexpected(backingIndex);
return new Change[] { change };
// }
}
use of liquibase.change.Change in project liquibase by liquibase.
the class UnexpectedSequenceChangeGenerator method fixUnexpected.
@Override
public Change[] fixUnexpected(DatabaseObject unexpectedObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
Sequence sequence = (Sequence) unexpectedObject;
DropSequenceChange change = new DropSequenceChange();
change.setSequenceName(sequence.getName());
if (control.getIncludeCatalog()) {
change.setCatalogName(sequence.getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(sequence.getSchema().getName());
}
return new Change[] { change };
}
use of liquibase.change.Change in project liquibase by liquibase.
the class UnexpectedTableChangeGenerator method fixUnexpected.
@Override
public Change[] fixUnexpected(DatabaseObject unexpectedObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
Table unexpectedTable = (Table) unexpectedObject;
DropTableChange change = new DropTableChange();
change.setTableName(unexpectedTable.getName());
if (control.getIncludeCatalog()) {
change.setCatalogName(unexpectedTable.getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(unexpectedTable.getSchema().getName());
}
for (Column column : unexpectedTable.getColumns()) {
control.setAlreadyHandledUnexpected(column);
}
;
control.setAlreadyHandledUnexpected(unexpectedTable.getPrimaryKey());
for (Index index : unexpectedTable.getIndexes()) {
control.setAlreadyHandledUnexpected(index);
}
control.setAlreadyHandledUnexpected(unexpectedTable.getPrimaryKey());
if (unexpectedTable.getPrimaryKey() != null) {
control.setAlreadyHandledUnexpected(unexpectedTable.getPrimaryKey().getBackingIndex());
}
return new Change[] { change };
}
use of liquibase.change.Change in project liquibase by liquibase.
the class UnexpectedUniqueConstraintChangeGenerator method fixUnexpected.
@Override
public Change[] fixUnexpected(DatabaseObject unexpectedObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
UniqueConstraint uc = (UniqueConstraint) unexpectedObject;
if (uc.getTable() == null) {
return null;
}
DropUniqueConstraintChange change = new DropUniqueConstraintChange();
change.setTableName(uc.getTable().getName());
if (control.getIncludeCatalog()) {
change.setCatalogName(uc.getTable().getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(uc.getTable().getSchema().getName());
}
change.setConstraintName(uc.getName());
Index backingIndex = uc.getBackingIndex();
// if (backingIndex == null) {
// Index exampleIndex = new Index().setTable(uc.getTable());
// for (String col : uc.getColumns()) {
// exampleIndex.getColumns().add(col);
// }
// control.setAlreadyHandledUnexpected(exampleIndex);
// } else {
control.setAlreadyHandledUnexpected(backingIndex);
return new Change[] { change };
}
use of liquibase.change.Change in project liquibase by liquibase.
the class UnexpectedViewChangeGenerator method fixUnexpected.
@Override
public Change[] fixUnexpected(DatabaseObject unexpectedObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
View view = (View) unexpectedObject;
DropViewChange change = new DropViewChange();
change.setViewName(view.getName());
if (control.getIncludeCatalog()) {
change.setCatalogName(view.getSchema().getCatalogName());
}
if (control.getIncludeSchema()) {
change.setSchemaName(view.getSchema().getName());
}
for (Column column : view.getColumns()) {
control.setAlreadyHandledUnexpected(column);
}
;
return new Change[] { change };
}
Aggregations