Database migration tool that enables versioned database schema evolution with simple SQL scripts and Java migrations
—
Comprehensive migration metadata and result objects providing detailed feedback on migration status, execution history, and operation outcomes.
/**
* Service providing access to migration information
*/
public interface MigrationInfoService {
/** Get all migrations (applied, pending, current) */
MigrationInfo[] all();
/** Get current migration */
MigrationInfo current();
/** Get pending migrations */
MigrationInfo[] pending();
/** Get applied migrations */
MigrationInfo[] applied();
/** Get resolved migrations */
MigrationInfo[] resolved();
/** Get failed migrations */
MigrationInfo[] failed();
/** Get out of order migrations */
MigrationInfo[] outOfOrder();
}/**
* Information about a single migration
*/
public interface MigrationInfo extends Comparable<MigrationInfo> {
/** The type of migration (SQL, JDBC, etc.) */
MigrationType getType();
/** The checksum of the migration */
Integer getChecksum();
/** The version of the migration */
MigrationVersion getVersion();
/** The description of the migration */
String getDescription();
/** The name of the script to execute for this migration */
String getScript();
/** The state of the migration (PENDING, SUCCESS, etc.) */
MigrationState getState();
/** The timestamp when this migration was installed */
Date getInstalledOn();
/** The user that installed this migration */
String getInstalledBy();
/** The execution time in milliseconds */
Integer getExecutionTime();
/** The rank of this installed migration */
Integer getInstalledRank();
/** Whether this migration can be executed in a transaction */
Boolean canExecuteInTransaction();
}/**
* The state of a migration
*/
public enum MigrationState {
/** This migration has not been applied yet */
PENDING,
/** This migration has succeeded */
SUCCESS,
/** This migration has failed */
FAILED,
/** This migration succeeded, but it was applied out of order */
OUT_OF_ORDER,
/** This migration succeeded, but it was applied in the future */
FUTURE_SUCCESS,
/** This migration failed, but it was applied in the future */
FUTURE_FAILED,
/** This migration version is newer than the target version */
ABOVE_TARGET,
/** This migration is below the baseline and won't be applied */
BELOW_BASELINE,
/** This is the baseline migration */
BASELINE
}// Get migration information
MigrationInfoService infoService = flyway.info();
// Display all migrations
for (MigrationInfo info : infoService.all()) {
System.out.printf("%s %s %s %s%n",
info.getVersion(),
info.getState(),
info.getDescription(),
info.getInstalledOn());
}
// Check for pending migrations
MigrationInfo[] pending = infoService.pending();
if (pending.length > 0) {
System.out.println("Pending migrations: " + pending.length);
}
// Get current version
MigrationInfo current = infoService.current();
if (current != null) {
System.out.println("Current version: " + current.getVersion());
}Install with Tessl CLI
npx tessl i tessl/maven-org-flywaydb--flyway-core