public interface JavaMigration
Java-based migrations are a great fit for all changes that can not easily be expressed using SQL.
These would typically be things like
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 BaseJavaMigration instead of implementing this
interface directly, as BaseJavaMigration encourages 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.
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
canExecuteInTransaction()
Whether the execution should take place inside a transaction.
|
Integer |
getChecksum()
Computes the checksum of the migration.
|
String |
getDescription() |
MigrationVersion |
getVersion() |
boolean |
isUndo()
Whether this is an undo migration for a previously applied versioned migration.
|
void |
migrate(Context context)
Executes this migration.
|
MigrationVersion getVersion()
null for repeatable migrations.String getDescription()
null.Integer getChecksum()
boolean isUndo()
true if it is, false if not. Always false for repeatable migrations.boolean canExecuteInTransaction()
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.true if a transaction should be used (highly recommended), or false if not.void migrate(Context context) throws Exception
true.context - The context relevant for this migration, containing things like the JDBC connection to use and the
current Flyway configuration.Exception - when the migration failed.Copyright © 2022. All rights reserved.