diff --git a/flyway-ant/src/main/java/org/flywaydb/ant/AbstractFlywayTask.java b/flyway-ant/src/main/java/org/flywaydb/ant/AbstractFlywayTask.java index 1951d82a31..1cb3e42f38 100644 --- a/flyway-ant/src/main/java/org/flywaydb/ant/AbstractFlywayTask.java +++ b/flyway-ant/src/main/java/org/flywaydb/ant/AbstractFlywayTask.java @@ -193,6 +193,15 @@ public void setCallbacks(String callbacks) { this.callbacks = StringUtils.tokenizeToStringArray(callbacks, ","); } + /** + * @param skipDefaultCallbacks Whether built-int callbacks should be skipped. + * If true, only custom callbacks are used.
(default: false)
+ *The name of the schema metadata table that will be used by Flyway.
By default (single-schema mode) the * metadata table is placed in the default schema for the connection provided by the datasource.
When the diff --git a/flyway-commandline/src/main/assembly/flyway.conf b/flyway-commandline/src/main/assembly/flyway.conf index 6ca9ad0702..091e47d1a3 100644 --- a/flyway-commandline/src/main/assembly/flyway.conf +++ b/flyway-commandline/src/main/assembly/flyway.conf @@ -154,3 +154,8 @@ flyway.url= # This allows you to tie in custom code and logic to the Flyway lifecycle notifications (default: empty). # Set this to a comma-separated list of fully qualified FlywayCallback class name implementations # flyway.callbacks= + +# If set to true, default built-in callbacks (sql) are skipped and only custom callback as +# defined by 'flyway.callbacks' are used. (default: false) +# flyway.skipDefaultResolvers= + diff --git a/flyway-commandline/src/main/java/org/flywaydb/commandline/Main.java b/flyway-commandline/src/main/java/org/flywaydb/commandline/Main.java index 69787be585..231b8429ee 100644 --- a/flyway-commandline/src/main/java/org/flywaydb/commandline/Main.java +++ b/flyway-commandline/src/main/java/org/flywaydb/commandline/Main.java @@ -244,6 +244,7 @@ private static void printUsage() { LOG.info("target : Target version up to which Flyway should use migrations"); LOG.info("outOfOrder : Allows migrations to be run \"out of order\""); LOG.info("callbacks : Comma-separated list of FlywayCallback classes"); + LOG.info("skipDefaultCallbacks : Skips default callbacks (sql)"); LOG.info("validateOnMigrate : Validate when running migrate"); LOG.info("cleanOnValidationError : Automatically clean on a validation error"); LOG.info("cleanDisabled : Whether to disable clean"); diff --git a/flyway-core/src/main/java/org/flywaydb/core/Flyway.java b/flyway-core/src/main/java/org/flywaydb/core/Flyway.java index cd7ddeee05..b941daea38 100644 --- a/flyway-core/src/main/java/org/flywaydb/core/Flyway.java +++ b/flyway-core/src/main/java/org/flywaydb/core/Flyway.java @@ -16,7 +16,9 @@ package org.flywaydb.core; -import org.flywaydb.core.api.*; +import org.flywaydb.core.api.FlywayException; +import org.flywaydb.core.api.MigrationInfoService; +import org.flywaydb.core.api.MigrationVersion; import org.flywaydb.core.api.callback.FlywayCallback; import org.flywaydb.core.api.configuration.FlywayConfiguration; import org.flywaydb.core.api.resolver.MigrationResolver; @@ -52,11 +54,14 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; /** * This is the centre point of Flyway, and for most users, the only class they will ever have to deal with. @@ -234,11 +239,17 @@ public class Flyway implements FlywayConfiguration { private boolean outOfOrder; /** - * This is a list of callbacks that fire before and after tasks are executed. You can - * add as many custom callbacks as you want. + * This is a list of custom callbacks that fire before and after tasks are executed. You can + * add as many custom callbacks as you want. (default: none) */ private FlywayCallback[] callbacks = new FlywayCallback[0]; + /** + * Whether Flyway should skip the default callbacks. If true, only custom callbacks are used. + *
(default: false)
+ */ + private boolean skipDefaultCallbacks; + /** * The custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply. *(default: none)
@@ -784,6 +795,11 @@ public FlywayCallback[] getCallbacks() { return callbacks; } + @Override + public boolean isSkipDefaultCallbacks() { + return skipDefaultCallbacks; + } + /** * Set the callbacks for lifecycle notifications. * @@ -803,6 +819,15 @@ public void setCallbacksAsClassNames(String... callbacks) { setCallbacks(callbackList.toArray(new FlywayCallback[callbacks.length])); } + /** + * Whether Flyway should skip the default callbacks. If true, only custom callbacks are used. + * + * @param skipDefaultCallbacks Whether default built-in callbacks should be skipped.(default: false)
+ */ + public void setSkipDefaultCallbacks(boolean skipDefaultCallbacks) { + this.skipDefaultCallbacks = skipDefaultCallbacks; + } + /** * Sets custom MigrationResolvers to be used in addition to the built-in ones for resolving Migrations to apply. * @@ -841,11 +866,12 @@ public void setSkipDefaultResolvers(boolean skipDefaultResolvers) { */ public int migrate() throws FlywayException { return execute(new Command