Class ColumnMigrator


  • public class ColumnMigrator
    extends Object
    Handles the migration of columns.
    Author:
    harald
    • Constructor Detail

      • ColumnMigrator

        public ColumnMigrator​(Entity entity,
                              Attribute attribute,
                              Backend backend,
                              ColumnMetaData... columns)
        Creates a column migrator.
        Parameters:
        entity - the migrated entity
        attribute - the model's attribute, null if drop columns
        backend - the backend
        columns - the database's column(s), null if add attribute
      • ColumnMigrator

        public ColumnMigrator​(Entity entity,
                              Attribute attribute,
                              Backend backend,
                              Collection<ColumnMetaData> columns)
        Creates a column migrator.
        Parameters:
        entity - the migrated entity
        attribute - the model's attribute, null if drop columns
        backend - the backend
        columns - the database's column(s), null or empty if add attribute
    • Method Detail

      • getBackend

        public Backend getBackend()
        Gets the backend.
        Returns:
        the backend
      • getAttribute

        public Attribute getAttribute()
        Gets the model's attribute.
        Returns:
        the model's attribute
      • getColumns

        public ColumnMetaData[] getColumns()
        Gets the database's column meta data.
        Returns:
        the database's column(s)
      • migrate

        public String migrate()
                       throws ModelException
        Migrates the column.
        Returns:
        the SQL code, empty string if nothing to migrate
        Throws:
        ModelException - if migration failed