Search in sources :

Example 1 with AlterSequenceChange

use of liquibase.change.core.AlterSequenceChange in project liquibase by liquibase.

the class ChangedSequenceChangeGenerator method fixChanged.

@Override
public Change[] fixChanged(DatabaseObject changedObject, ObjectDifferences differences, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
    Sequence sequence = (Sequence) changedObject;
    List<Change> changes = new ArrayList<Change>();
    if (differences.isDifferent("incrementBy")) {
        AlterSequenceChange change = createAlterSequenceChange(sequence, control);
        change.setIncrementBy(sequence.getIncrementBy());
        changes.add(change);
    }
    if (differences.isDifferent("maxValue")) {
        AlterSequenceChange change = createAlterSequenceChange(sequence, control);
        change.setMaxValue(sequence.getMaxValue());
        changes.add(change);
    }
    if (differences.isDifferent("ordered")) {
        AlterSequenceChange change = createAlterSequenceChange(sequence, control);
        change.setOrdered(sequence.getOrdered());
        changes.add(change);
    }
    if (differences.isDifferent("cacheSize")) {
        AlterSequenceChange change = createAlterSequenceChange(sequence, control);
        change.setCacheSize(sequence.getCacheSize());
        changes.add(change);
    }
    if (differences.isDifferent("willCycle")) {
        AlterSequenceChange change = createAlterSequenceChange(sequence, control);
        change.setCycle(sequence.getWillCycle());
        changes.add(change);
    }
    if (changes.size() == 0) {
        return null;
    } else {
        return changes.toArray(new Change[changes.size()]);
    }
}
Also used : ArrayList(java.util.ArrayList) Sequence(liquibase.structure.core.Sequence) AlterSequenceChange(liquibase.change.core.AlterSequenceChange) Change(liquibase.change.Change) AlterSequenceChange(liquibase.change.core.AlterSequenceChange)

Example 2 with AlterSequenceChange

use of liquibase.change.core.AlterSequenceChange in project liquibase by liquibase.

the class ChangedSequenceChangeGenerator method createAlterSequenceChange.

protected AlterSequenceChange createAlterSequenceChange(Sequence sequence, DiffOutputControl control) {
    AlterSequenceChange change = new AlterSequenceChange();
    if (control.getIncludeCatalog()) {
        change.setCatalogName(sequence.getSchema().getCatalogName());
    }
    if (control.getIncludeSchema()) {
        change.setSchemaName(sequence.getSchema().getName());
    }
    change.setSequenceName(sequence.getName());
    return change;
}
Also used : AlterSequenceChange(liquibase.change.core.AlterSequenceChange)

Aggregations

AlterSequenceChange (liquibase.change.core.AlterSequenceChange)2 ArrayList (java.util.ArrayList)1 Change (liquibase.change.Change)1 Sequence (liquibase.structure.core.Sequence)1