Class IndexMigrator


  • public class IndexMigrator
    extends java.lang.Object
    Handles the migration of indexes.
    Author:
    harald
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IndexMigrator.Result
      Migration result.
    • Constructor Summary

      Constructors 
      Constructor Description
      IndexMigrator​(Entity entity, Index index, org.tentackle.sql.Backend backend, org.tentackle.sql.metadata.IndexMetaData indexMetaData)
      Creates a migrator.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.tentackle.sql.Backend getBackend()
      Gets the backend.
      Index getIndex()
      Gets the index to migrate.
      org.tentackle.sql.metadata.IndexMetaData getIndexMetaData()
      Gets the index metadata.
      static boolean isLogicallyDifferent​(Index modelIndex, org.tentackle.sql.metadata.IndexMetaData dbIndex, java.lang.StringBuilder commentBuf)
      Compares an model index with an existing database index.
      IndexMigrator.Result migrate()
      Migrates the index.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IndexMigrator

        public IndexMigrator​(Entity entity,
                             Index index,
                             org.tentackle.sql.Backend backend,
                             org.tentackle.sql.metadata.IndexMetaData indexMetaData)
        Creates a migrator.
        Parameters:
        entity - the entity
        index - the index to migrate, null if no such index in model
        backend - the backend
        indexMetaData - the foreign meta data, null if key does not exist
    • Method Detail

      • getBackend

        public org.tentackle.sql.Backend getBackend()
        Gets the backend.
        Returns:
        the backend
      • getIndex

        public Index getIndex()
        Gets the index to migrate.
        Returns:
        the index, null if no such index in model
      • getIndexMetaData

        public org.tentackle.sql.metadata.IndexMetaData getIndexMetaData()
        Gets the index metadata.
        Returns:
        the meta date, null if no such index in database
      • migrate

        public IndexMigrator.Result migrate()
        Migrates the index.
        Returns:
        the SQL code, empty string if nothing to migrate
      • isLogicallyDifferent

        public static boolean isLogicallyDifferent​(Index modelIndex,
                                                   org.tentackle.sql.metadata.IndexMetaData dbIndex,
                                                   java.lang.StringBuilder commentBuf)
        Compares an model index with an existing database index.
        Parameters:
        modelIndex - the index as defined in the model
        dbIndex - the index existing in the database
        commentBuf - comment buffer to show the difference, null if none
        Returns:
        true if they are different, false if logically equal