Search in sources :

Example 11 with Change

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 };
//        }
}
Also used : DropPrimaryKeyChange(liquibase.change.core.DropPrimaryKeyChange) DropPrimaryKeyChange(liquibase.change.core.DropPrimaryKeyChange) Change(liquibase.change.Change)

Example 12 with 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 };
}
Also used : DropSequenceChange(liquibase.change.core.DropSequenceChange) Sequence(liquibase.structure.core.Sequence) DropSequenceChange(liquibase.change.core.DropSequenceChange) Change(liquibase.change.Change)

Example 13 with 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 };
}
Also used : DropTableChange(liquibase.change.core.DropTableChange) Change(liquibase.change.Change) DropTableChange(liquibase.change.core.DropTableChange)

Example 14 with 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 };
}
Also used : DropUniqueConstraintChange(liquibase.change.core.DropUniqueConstraintChange) DropUniqueConstraintChange(liquibase.change.core.DropUniqueConstraintChange) Change(liquibase.change.Change)

Example 15 with 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 };
}
Also used : Column(liquibase.structure.core.Column) DropViewChange(liquibase.change.core.DropViewChange) DropViewChange(liquibase.change.core.DropViewChange) Change(liquibase.change.Change) View(liquibase.structure.core.View)

Aggregations

Change (liquibase.change.Change)44 ArrayList (java.util.ArrayList)9 Column (liquibase.structure.core.Column)9 ChangeSet (liquibase.changelog.ChangeSet)7 DatabaseObject (liquibase.structure.DatabaseObject)7 DbmsTargetedChange (liquibase.change.DbmsTargetedChange)6 EmptyChange (liquibase.change.core.EmptyChange)6 RawSQLChange (liquibase.change.core.RawSQLChange)6 OracleDatabase (liquibase.database.core.OracleDatabase)6 Database (liquibase.database.Database)4 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)4 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)4 AddColumnConfig (liquibase.change.AddColumnConfig)3 ChangeFactory (liquibase.change.ChangeFactory)3 ChangeMetaData (liquibase.change.ChangeMetaData)3 ChangeParameterMetaData (liquibase.change.ChangeParameterMetaData)3 CreateIndexChange (liquibase.change.core.CreateIndexChange)3 Difference (liquibase.diff.Difference)3 Executor (liquibase.executor.Executor)3 ParsedNodeException (liquibase.parser.core.ParsedNodeException)3