Class TableMigrator


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

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

      Constructors 
      Constructor Description
      TableMigrator​(Entity entity, java.util.Collection<ForeignKey> foreignKeys, org.tentackle.sql.Backend backend, org.tentackle.sql.metadata.TableMetaData table)
      Creates a table migrator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.tentackle.sql.Backend getBackend()
      Gets the backend.
      Entity getEntity()
      Gets the model's entity.
      org.tentackle.sql.metadata.TableMetaData getTable()
      Gets the database's table meta data.
      TableMigrator.Result migrate​(java.util.Collection<java.util.regex.Pattern> hints, java.util.Collection<ColumnMigration> columnMigrations)
      Create SQL code to migrate the table.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • TableMigrator

        public TableMigrator​(Entity entity,
                             java.util.Collection<ForeignKey> foreignKeys,
                             org.tentackle.sql.Backend backend,
                             org.tentackle.sql.metadata.TableMetaData table)
        Creates a table migrator.
        Parameters:
        entity - the model's entity
        foreignKeys - the foreign keys related to given entity
        backend - the backend
        table - the database's table meta data
    • Method Detail

      • getBackend

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

        public Entity getEntity()
        Gets the model's entity.
        Returns:
        the model's entity
      • getTable

        public org.tentackle.sql.metadata.TableMetaData getTable()
        Gets the database's table meta data.
        Returns:
        the database's table meta data
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • migrate

        public TableMigrator.Result migrate​(java.util.Collection<java.util.regex.Pattern> hints,
                                            java.util.Collection<ColumnMigration> columnMigrations)
                                     throws ModelException
        Create SQL code to migrate the table.
        Parameters:
        hints - hints to control the created output
        columnMigrations - explicit column migrations, null if none
        Returns:
        the migration result
        Throws:
        ModelException - if migration failed