updating the version of flyway-core and changing the callback implementation.
This commit is contained in:
+21
-14
@@ -1,33 +1,40 @@
|
||||
package com.baeldung.flywaycallbacks;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.flywaydb.core.api.MigrationInfo;
|
||||
import org.flywaydb.core.api.callback.BaseFlywayCallback;
|
||||
import org.flywaydb.core.api.callback.Callback;
|
||||
import org.flywaydb.core.api.callback.Context;
|
||||
import org.flywaydb.core.api.callback.Event;
|
||||
|
||||
public class ExampleFlywayCallback extends BaseFlywayCallback {
|
||||
public class ExampleFlywayCallback implements Callback {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass());
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public void afterEachMigrate(Connection connection, MigrationInfo info) {
|
||||
log.info("> afterEachMigrate");
|
||||
public boolean supports(Event event, Context context) {
|
||||
return event == Event.AFTER_EACH_MIGRATE || event == Event.AFTER_MIGRATE || event == Event.BEFORE_EACH_MIGRATE || event == Event.BEFORE_MIGRATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterMigrate(Connection connection) {
|
||||
log.info("> afterMigrate");
|
||||
public boolean canHandleInTransaction(Event event, Context context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachMigrate(Connection connection, MigrationInfo info) {
|
||||
log.info("> beforeEachMigrate");
|
||||
public void handle(Event event, Context context) {
|
||||
if (event == Event.AFTER_EACH_MIGRATE) {
|
||||
log.info("> afterEachMigrate");
|
||||
} else if (event == Event.AFTER_MIGRATE) {
|
||||
log.info("> afterMigrate");
|
||||
} else if (event == Event.BEFORE_EACH_MIGRATE) {
|
||||
log.info("> beforeEachMigrate");
|
||||
} else if (event == Event.BEFORE_MIGRATE) {
|
||||
log.info("> beforeMigrate");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMigrate(Connection connection) {
|
||||
log.info("> beforeMigrate");
|
||||
public String getCallbackName() {
|
||||
return ExampleFlywayCallback.class.getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user