Search in sources :

Example 6 with ObjectDifferences

use of liquibase.diff.ObjectDifferences in project liquibase by liquibase.

the class IndexComparator method findDifferences.

@Override
public ObjectDifferences findDifferences(DatabaseObject databaseObject1, DatabaseObject databaseObject2, Database accordingTo, CompareControl compareControl, DatabaseObjectComparatorChain chain, Set<String> exclude) {
    exclude.add("name");
    exclude.add("columns");
    ObjectDifferences differences = chain.findDifferences(databaseObject1, databaseObject2, accordingTo, compareControl, exclude);
    differences.compare("columns", databaseObject1, databaseObject2, new ObjectDifferences.CompareFunction() {

        @Override
        public boolean areEqual(Object referenceValue, Object compareToValue) {
            List<Column> referenceList = (List) referenceValue;
            List<Column> compareList = (List) compareToValue;
            if (referenceList.size() != compareList.size()) {
                return false;
            }
            for (int i = 0; i < referenceList.size(); i++) {
                if (!StringUtils.trimToEmpty((referenceList.get(i)).getName()).equalsIgnoreCase(StringUtils.trimToEmpty(compareList.get(i).getName()))) {
                    return false;
                }
            }
            return true;
        }
    });
    return differences;
}
Also used : ObjectDifferences(liquibase.diff.ObjectDifferences) DatabaseObject(liquibase.structure.DatabaseObject)

Example 7 with ObjectDifferences

use of liquibase.diff.ObjectDifferences in project liquibase by liquibase.

the class SchemaComparator method findDifferences.

@Override
public ObjectDifferences findDifferences(DatabaseObject databaseObject1, DatabaseObject databaseObject2, Database accordingTo, CompareControl compareControl, DatabaseObjectComparatorChain chain, Set<String> exclude) {
    ObjectDifferences differences = new ObjectDifferences(compareControl);
    differences.compare("name", databaseObject1, databaseObject2, new ObjectDifferences.DatabaseObjectNameCompareFunction(Schema.class, accordingTo));
    return differences;
}
Also used : ObjectDifferences(liquibase.diff.ObjectDifferences) CatalogAndSchema(liquibase.CatalogAndSchema) Schema(liquibase.structure.core.Schema)

Example 8 with ObjectDifferences

use of liquibase.diff.ObjectDifferences in project liquibase by liquibase.

the class TableComparator method findDifferences.

@Override
public ObjectDifferences findDifferences(DatabaseObject databaseObject1, DatabaseObject databaseObject2, Database accordingTo, CompareControl compareControl, DatabaseObjectComparatorChain chain, Set<String> exclude) {
    exclude.add("indexes");
    exclude.add("name");
    exclude.add("outgoingForeignKeys");
    exclude.add("uniqueConstraints");
    exclude.add("primaryKey");
    exclude.add("columns");
    exclude.add("schema");
    ObjectDifferences differences = chain.findDifferences(databaseObject1, databaseObject2, accordingTo, compareControl, exclude);
    differences.compare("name", databaseObject1, databaseObject2, new ObjectDifferences.DatabaseObjectNameCompareFunction(Table.class, accordingTo));
    return differences;
}
Also used : Table(liquibase.structure.core.Table) ObjectDifferences(liquibase.diff.ObjectDifferences)

Example 9 with ObjectDifferences

use of liquibase.diff.ObjectDifferences in project liquibase by liquibase.

the class UniqueConstraintComparator method findDifferences.

@Override
public ObjectDifferences findDifferences(DatabaseObject databaseObject1, DatabaseObject databaseObject2, Database accordingTo, CompareControl compareControl, DatabaseObjectComparatorChain chain, Set<String> exclude) {
    exclude.add("name");
    exclude.add("columns");
    exclude.add("backingIndex");
    ObjectDifferences differences = chain.findDifferences(databaseObject1, databaseObject2, accordingTo, compareControl, exclude);
    differences.compare("columns", databaseObject1, databaseObject2, new ObjectDifferences.CompareFunction() {

        @Override
        public boolean areEqual(Object referenceValue, Object compareToValue) {
            List<Column> referenceList = (List) referenceValue;
            List<Column> compareList = (List) compareToValue;
            if (referenceList.size() != compareList.size()) {
                return false;
            }
            for (int i = 0; i < referenceList.size(); i++) {
                if (!StringUtils.trimToEmpty((referenceList.get(i)).getName()).equalsIgnoreCase(StringUtils.trimToEmpty(compareList.get(i).getName()))) {
                    return false;
                }
            }
            return true;
        }
    });
    differences.compare("backingIndex", databaseObject1, databaseObject2, new ObjectDifferences.StandardCompareFunction(chain.getSchemaComparisons(), accordingTo));
    return differences;
}
Also used : ObjectDifferences(liquibase.diff.ObjectDifferences) DatabaseObject(liquibase.structure.DatabaseObject) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with ObjectDifferences

use of liquibase.diff.ObjectDifferences in project liquibase by liquibase.

the class CatalogComparator method findDifferences.

@Override
public ObjectDifferences findDifferences(DatabaseObject databaseObject1, DatabaseObject databaseObject2, Database accordingTo, CompareControl compareControl, DatabaseObjectComparatorChain chain, Set<String> exclude) {
    ObjectDifferences differences = new ObjectDifferences(compareControl);
    differences.compare("name", databaseObject1, databaseObject2, new ObjectDifferences.DatabaseObjectNameCompareFunction(Schema.class, accordingTo));
    return differences;
}
Also used : ObjectDifferences(liquibase.diff.ObjectDifferences) CatalogAndSchema(liquibase.CatalogAndSchema) Schema(liquibase.structure.core.Schema)

Aggregations

ObjectDifferences (liquibase.diff.ObjectDifferences)10 DatabaseObject (liquibase.structure.DatabaseObject)5 Column (liquibase.structure.core.Column)4 List (java.util.List)2 CatalogAndSchema (liquibase.CatalogAndSchema)2 Schema (liquibase.structure.core.Schema)2 Table (liquibase.structure.core.Table)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Change (liquibase.change.Change)1 ChangeSet (liquibase.changelog.ChangeSet)1 GlobalConfiguration (liquibase.configuration.GlobalConfiguration)1 ObjectQuotingStrategy (liquibase.database.ObjectQuotingStrategy)1 DatabaseObjectComparator (liquibase.structure.DatabaseObjectComparator)1 DataType (liquibase.structure.core.DataType)1