Interface MigrationExecutor


public interface MigrationExecutor
Executes a migration.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether the execution can take place inside a transaction.
    void
    execute(Context context)
    Executes the migration this executor is associated with.
    boolean
    Whether the migration associated with this executor should be executed or not.
    default String
    Optionally, an executor may provide an expression string describing the conditions under which shouldExecute may return true.
  • Method Details

    • execute

      void execute(Context context) throws SQLException
      Executes the migration this executor is associated with.
      Parameters:
      context - The context to use to execute the migration against the DB.
      Throws:
      SQLException - when the execution of a statement failed.
    • canExecuteInTransaction

      boolean canExecuteInTransaction()
      Whether the execution can take place inside a transaction. Almost all implementation should return true. This however makes it possible to execute certain migrations outside a transaction. This is useful for databases like PostgreSQL and SQL Server where certain statement can only execute outside a transaction.
      Returns:
      true if a transaction should be used (highly recommended), or false if not.
    • shouldExecute

      boolean shouldExecute()
      Whether the migration associated with this executor should be executed or not.
      Returns:
      true if the migration should be executed, or false if not.
    • shouldExecuteExpression

      default String shouldExecuteExpression()
      Optionally, an executor may provide an expression string describing the conditions under which shouldExecute may return true. The shouldExecute function itself is the source of truth for whether a script may execute, this function is provided for providing additional information rather than direct evaluation.
      Returns:
      A string expression for the shouldExecute function, or null