Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public interface MigrationCallback

Code run at a point of a migration run, as Flyway’s Callback is: before and after migrate, each migration, validate, undo and the other commands. A SQL script named after the event (beforeMigrate.sql, afterEachMigrate__grants.sql) is the other kind; both run, scripts first.

The events are the constants of this interface, spelled as Flyway spells them.

Fields

public static final String BEFORE_MIGRATE = "beforeMigrate"
public static final String BEFORE_EACH_MIGRATE = "beforeEachMigrate"
public static final String AFTER_EACH_MIGRATE = "afterEachMigrate"
public static final String AFTER_EACH_MIGRATE_ERROR = "afterEachMigrateError"
public static final String AFTER_MIGRATE = "afterMigrate"
public static final String AFTER_MIGRATE_ERROR = "afterMigrateError"
public static final String BEFORE_UNDO = "beforeUndo"
public static final String BEFORE_EACH_UNDO = "beforeEachUndo"
public static final String AFTER_EACH_UNDO = "afterEachUndo"
public static final String AFTER_UNDO = "afterUndo"
public static final String AFTER_UNDO_ERROR = "afterUndoError"
public static final String BEFORE_VALIDATE = "beforeValidate"
public static final String AFTER_VALIDATE = "afterValidate"
public static final String AFTER_VALIDATE_ERROR = "afterValidateError"
public static final String BEFORE_CLEAN = "beforeClean"
public static final String AFTER_CLEAN = "afterClean"
public static final String BEFORE_INFO = "beforeInfo"
public static final String AFTER_INFO = "afterInfo"
public static final String BEFORE_REPAIR = "beforeRepair"
public static final String AFTER_REPAIR = "afterRepair"
public static final String BEFORE_BASELINE = "beforeBaseline"
public static final String AFTER_BASELINE = "afterBaseline"

Methods

public abstract boolean supports(String event)Whether to be called for event.
public abstract void handle(String event, MigrationContext context) throws ExceptionRuns for event.

Field details

BEFORE_MIGRATE

public static final String BEFORE_MIGRATE = "beforeMigrate"

BEFORE_EACH_MIGRATE

public static final String BEFORE_EACH_MIGRATE = "beforeEachMigrate"

AFTER_EACH_MIGRATE

public static final String AFTER_EACH_MIGRATE = "afterEachMigrate"

AFTER_EACH_MIGRATE_ERROR

public static final String AFTER_EACH_MIGRATE_ERROR = "afterEachMigrateError"

AFTER_MIGRATE

public static final String AFTER_MIGRATE = "afterMigrate"

AFTER_MIGRATE_ERROR

public static final String AFTER_MIGRATE_ERROR = "afterMigrateError"

BEFORE_UNDO

public static final String BEFORE_UNDO = "beforeUndo"

BEFORE_EACH_UNDO

public static final String BEFORE_EACH_UNDO = "beforeEachUndo"

AFTER_EACH_UNDO

public static final String AFTER_EACH_UNDO = "afterEachUndo"

AFTER_UNDO

public static final String AFTER_UNDO = "afterUndo"

AFTER_UNDO_ERROR

public static final String AFTER_UNDO_ERROR = "afterUndoError"

BEFORE_VALIDATE

public static final String BEFORE_VALIDATE = "beforeValidate"

AFTER_VALIDATE

public static final String AFTER_VALIDATE = "afterValidate"

AFTER_VALIDATE_ERROR

public static final String AFTER_VALIDATE_ERROR = "afterValidateError"

BEFORE_CLEAN

public static final String BEFORE_CLEAN = "beforeClean"

AFTER_CLEAN

public static final String AFTER_CLEAN = "afterClean"

BEFORE_INFO

public static final String BEFORE_INFO = "beforeInfo"

AFTER_INFO

public static final String AFTER_INFO = "afterInfo"

BEFORE_REPAIR

public static final String BEFORE_REPAIR = "beforeRepair"

AFTER_REPAIR

public static final String AFTER_REPAIR = "afterRepair"

BEFORE_BASELINE

public static final String BEFORE_BASELINE = "beforeBaseline"

AFTER_BASELINE

public static final String AFTER_BASELINE = "afterBaseline"

Method details

supports

public abstract boolean supports(String event)
Whether to be called for event.

handle

public abstract void handle(String event, MigrationContext context) throws Exception
Runs for event. A failure of a before event stops the command; a failure of an afterEach...Error or ...Error event is logged under the failure that caused it.

Throws

Exception