- All Known Implementing Classes:
public interface JavaMigrationInterface to be implemented by Java-based Migrations.
Java-based migrations are a great fit for all changes that can not easily be expressed using SQL.
These would typically be things like
- BLOB & CLOB changes
- Advanced bulk data changes (Recalculations, advanced format changes, …)
Migration classes implementing this interface will be automatically discovered when placed in a location on the classpath.
Most users will be better served by subclassing subclass
BaseJavaMigrationinstead of implementing this interface directly, as
BaseJavaMigrationencourages the use of Flyway's default naming convention and comes with sensible default implementations of all methods (except migrate of course) while at the same time also providing better isolation against future additions to this interface.
All Methods Instance Methods Abstract Methods Modifier and Type Method Description
canExecuteInTransaction()Whether the execution should take place inside a transaction.
isBaselineMigration()Whether this is a baseline migration.
isUndo()Whether this is an undo migration for a previously applied versioned migration.
migrate(Context context)Executes this migration.
- The version of the schema after the migration is complete.
nullfor repeatable migrations.
- The description of this migration for the migration history. Never
- The checksum of this migration.
boolean isUndo()Whether this is an undo migration for a previously applied versioned migration.
trueif it is,
falseif not. Always
falsefor repeatable migrations.
boolean isBaselineMigration()Whether this is a baseline migration.
trueif it is,
boolean canExecuteInTransaction()Whether the execution should take place inside a transaction. Almost all implementations 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.
trueif a transaction should be used (highly recommended), or
void migrate(Context context) throws java.lang.ExceptionExecutes this migration. The execution will automatically take place within a transaction, when the underlying database supports it and the canExecuteInTransaction returns
context- The context relevant for this migration, containing things like the JDBC connection to use and the current Flyway configuration.
java.lang.Exception- when the migration failed.