Class MigrationTable

java.lang.Object
io.ebean.migration.runner.MigrationTable

public class MigrationTable extends Object
Manages the migration table.
  • Constructor Details

    • MigrationTable

      public MigrationTable(MigrationConfig config, Connection connection, boolean checkState, MigrationPlatform platform)
      Construct with server, configuration and jdbc connection (DB admin user).
  • Method Details

    • size

      public int size()
      Return the number of migrations in the DB migration table.
    • getVersions

      @Nonnull public Set<String> getVersions()
      Returns the versions that are already applied.
    • createIfNeededAndLock

      public void createIfNeededAndLock() throws SQLException, IOException
      Create the table is it does not exist.

      Also holds DB lock on migration table and loads existing migrations.

      Throws:
      SQLException
      IOException
    • unlockMigrationTable

      public void unlockMigrationTable() throws SQLException
      Release a lock on the migration table (MySql, MariaDB only).
      Throws:
      SQLException
    • isEmpty

      public boolean isEmpty()
      Return true if there are no migrations.
    • runAll

      @Nonnull public List<LocalMigrationResource> runAll(List<LocalMigrationResource> localVersions) throws SQLException
      Run all the migrations in order as needed.
      Returns:
      the migrations that have been run (collected if checkstate is true).
      Throws:
      SQLException
    • runInit

      @Nonnull public List<LocalMigrationResource> runInit(LocalMigrationResource initVersion, List<LocalMigrationResource> localVersions) throws SQLException
      Run using an init migration.
      Returns:
      the migrations that have been run (collected if checkstate is true).
      Throws:
      SQLException
    • runNonTransactional

      public void runNonTransactional()
      Run non transactional statements (if any) after migration commit.

      These run with auto commit true and run AFTER the migration commit and as such the migration isn't truely atomic - the migration can run and complete and the non-transactional statements fail.