Package org.jumpmind.db.alter
Class ModelComparator
java.lang.Object
org.jumpmind.db.alter.ModelComparator
Compares two database models and creates change objects that express how to adapt the first model so that it becomes the second one. Neither of the models
are changed in the process, however, it is also assumed that the models do not change in between.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether comparison is case sensitive.protected IDdlBuilder
protected DatabaseInfo
The platform information. -
Constructor Summary
ConstructorsConstructorDescriptionModelComparator
(IDdlBuilder ddlBuilder, DatabaseInfo platformInfo, boolean caseSensitive) Creates a new model comparator object. -
Method Summary
Modifier and TypeMethodDescriptionCompares the two models and returns the changes necessary to create the second model from the first one.compareColumns
(Table sourceTable, Column sourceColumn, Table targetTable, Column targetColumn) Compares the two columns and returns the changes necessary to create the second column from the first one.compareTables
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable) Compares the two tables and returns the changes necessary to create the second table from the first one.void
detectColumnChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected column changes (necessary to create the targetTable from the sourceTable) to specified list.void
detectForeignKeyChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected ForeignKey changes (necessary to create the targetTable from the sourceTable) to specified list.void
detectIndexChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected index changes (necessary to create the targetTable from the sourceTable) to specified list.void
detectLoggingChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected logging mode changes (necessary to create the targetTable from the sourceTable) to specified list.void
detectPrimaryKeyChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected primary key & related column changes (necessary to create the targetTable from the sourceTable) to specified list.void
detectTriggerChanges
(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes)
-
Field Details
-
platformInfo
The platform information. -
caseSensitive
protected boolean caseSensitiveWhether comparison is case sensitive. -
ddlBuilder
-
-
Constructor Details
-
ModelComparator
Creates a new model comparator object.- Parameters:
platformInfo
- The platform infocaseSensitive
- Whether comparison is case sensitive
-
-
Method Details
-
compare
Compares the two models and returns the changes necessary to create the second model from the first one.- Parameters:
sourceModel
- The source modeltargetModel
- The target model- Returns:
- The changes
-
compareTables
public List<IModelChange> compareTables(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable) Compares the two tables and returns the changes necessary to create the second table from the first one.- Parameters:
sourceModel
- The source model which contains the source tablesourceTable
- The source tabletargetModel
- The target model which contains the target tabletargetTable
- The target table- Returns:
- The changes
-
detectLoggingChanges
public void detectLoggingChanges(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected logging mode changes (necessary to create the targetTable from the sourceTable) to specified list. -
detectForeignKeyChanges
public void detectForeignKeyChanges(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected ForeignKey changes (necessary to create the targetTable from the sourceTable) to specified list. -
detectIndexChanges
public void detectIndexChanges(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected index changes (necessary to create the targetTable from the sourceTable) to specified list. -
detectColumnChanges
public void detectColumnChanges(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected column changes (necessary to create the targetTable from the sourceTable) to specified list. -
detectPrimaryKeyChanges
public void detectPrimaryKeyChanges(Database sourceModel, Table sourceTable, Database targetModel, Table targetTable, ArrayList<IModelChange> changes) Compares tables and appends detected primary key & related column changes (necessary to create the targetTable from the sourceTable) to specified list. -
detectTriggerChanges
-
compareColumns
public List<TableChange> compareColumns(Table sourceTable, Column sourceColumn, Table targetTable, Column targetColumn) Compares the two columns and returns the changes necessary to create the second column from the first one.- Parameters:
sourceTable
- The source table which contains the source columnsourceColumn
- The source columntargetTable
- The target table which contains the target columntargetColumn
- The target column- Returns:
- The changes
-