java.lang.Object
org.tentackle.model.migrate.IndexMigrator
Handles the migration of indexes.
- Author:
- harald
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionIndexMigrator(Entity entity, Index index, Backend backend, IndexMetaData indexMetaData) Creates a migrator. -
Method Summary
Modifier and TypeMethodDescriptionGets the backend.Gets the migrated entity.getIndex()Gets the index to migrate.Gets the index metadata.static booleanisLogicallyDifferent(Backend backend, Index modelIndex, IndexMetaData dbIndex, StringBuilder commentBuf) Compares a model index with an existing database index.migrate()Migrates the index.
-
Constructor Details
-
IndexMigrator
Creates a migrator.- Parameters:
entity- the entityindex- the index to migrate, null if no such index in modelbackend- the backendindexMetaData- the foreign metadata, null if key does not exist
-
-
Method Details
-
getBackend
Gets the backend.- Returns:
- the backend
-
getEntity
Gets the migrated entity.- Returns:
- the entity
-
getIndex
Gets the index to migrate.- Returns:
- the index, null if no such index in model
-
getIndexMetaData
Gets the index metadata.- Returns:
- the meta date, null if no such index in database
-
migrate
Migrates the index.- Returns:
- the SQL code, empty string if nothing to migrate
-
isLogicallyDifferent
public static boolean isLogicallyDifferent(Backend backend, Index modelIndex, IndexMetaData dbIndex, StringBuilder commentBuf) Compares a model index with an existing database index.- Parameters:
backend- the backendmodelIndex- the index as defined in the modeldbIndex- the index existing in the databasecommentBuf- comment buffer to show the difference, null if none- Returns:
- true if they are different, false if logically equal
-