Class ColumnMigrator

java.lang.Object
org.tentackle.model.migrate.ColumnMigrator

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

    • 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 Details

    • getBackend

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

      public Entity getEntity()
      Gets the migrated entity.
      Returns:
      the entity
    • getAttribute

      public Attribute getAttribute()
      Gets the model's attribute.
      Returns:
      the model's attribute, null if drop columns
    • 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