java.lang.Object
io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite

public class DdlWrite extends Object
Write context holding the buffers for both apply and rollback DDL. Description of the apply buffers:
  • applyDropDependencies: Contains drops for foreign keys, indices, constraint or drop history table
  • apply: Contains @DbMigraion.before, create table, create sequence or disable system versioning statements
  • applyAlterTables: Contains table alters (only that change the table data structure, there may be table alters like constraints etc. in postAlter)
  • applyPostAlter: Contains check constraints, unique constraints (which CAN be an index), column and table comments, @DbMigraion.after, drop tables, drop sequences or enable system versioning statement
  • applyForeignKeys: Contains foreign keys and indices.
  • applyHistoryView: The views for trigger based history support
  • applyHistoryTrigger: The triggers for trigger based history support
  • Constructor Details

  • Method Details

    • getOptions

      Return the DDL options.
    • getTable

      public MTable getTable(String tableName)
      Return the Table information from the current model.

      This is typically required for the history support (used to determine the list of columns included in the history when creating or recreating the associated trigger/stored procedure).

    • isApplyEmpty

      public boolean isApplyEmpty()
      Return true if the apply buffers are all empty.
    • applyPostAlter

      Return the buffer that POST ALTER is written to.
    • apply

      public DdlBuffer apply()
      Return the buffer that APPLY DDL is written to.
    • applyDropDependencies

      Return the buffer that executes early to drop dependencies like views etc.
    • applyAlterTable

      Creates or returns the DdlAlterTable statement for tablename. Note: All alters on a particular table are sorted in natural order in the ddl script. This allows optimizing the alters by merging them or doing a reorg table after altering is done.
      Parameters:
      tableName - the table name
      factory - the factory to construct a new object
      Returns:
    • applyForeignKeys

      Return the buffer that APPLY DDL is written to for foreign keys and their associated indexes.

      Statements added to this buffer are executed after all the normal apply statements and typically 'add foreign key' is added to this buffer.

    • dropAllForeignKeys

      Return the buffer used for the 'drop all DDL' for dropping foreign keys and associated indexes.
    • dropAll

      public DdlBuffer dropAll()
      Return the buffer used for the 'drop all DDL' to drop tables, views and history triggers etc.
    • writeApply

      public void writeApply(Appendable target) throws IOException
      Writes the apply ddl to the target.
      Throws:
      IOException
    • writeDropAll

      public void writeDropAll(Appendable target) throws IOException
      Writes the drop all ddl to the target.
      Throws:
      IOException
    • toString

      public String toString()
      Returns all create statements. Mainly used for unit-tests
      Overrides:
      toString in class Object