Commit 278b20d9 authored by Semyon Danilov's avatar Semyon Danilov Committed by Andy Wilkinson

Upgrade to Flyway 6.0.1

See gh-17997
parent 1e2f8959
......@@ -30,7 +30,6 @@ import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationVersion;
import org.flywaydb.core.api.callback.Callback;
import org.flywaydb.core.api.callback.FlywayCallback;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.springframework.beans.factory.ObjectProvider;
......@@ -81,6 +80,7 @@ import org.springframework.util.StringUtils;
* @author Dominic Gunn
* @author Dan Zheng
* @author András Deák
* @author Semyon Danilov
* @since 1.1.0
*/
@SuppressWarnings("deprecation")
......@@ -113,7 +113,7 @@ public class FlywayAutoConfiguration {
ResourceLoader resourceLoader, ObjectProvider<DataSource> dataSource,
@FlywayDataSource ObjectProvider<DataSource> flywayDataSource,
ObjectProvider<FlywayConfigurationCustomizer> fluentConfigurationCustomizers,
ObjectProvider<Callback> callbacks, ObjectProvider<FlywayCallback> flywayCallbacks) {
ObjectProvider<Callback> callbacks) {
FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader());
DataSource dataSourceToMigrate = configureDataSource(configuration, properties, dataSourceProperties,
flywayDataSource.getIfAvailable(), dataSource.getIfAvailable());
......@@ -122,10 +122,8 @@ public class FlywayAutoConfiguration {
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
configureCallbacks(configuration, orderedCallbacks);
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
Flyway flyway = configuration.load();
List<FlywayCallback> orderedFlywayCallbacks = flywayCallbacks.orderedStream().collect(Collectors.toList());
configureFlywayCallbacks(flyway, orderedCallbacks, orderedFlywayCallbacks);
return flyway;
configureFlywayCallbacks(configuration, orderedCallbacks);
return configuration.load();
}
private DataSource configureDataSource(FluentConfiguration configuration, FlywayProperties properties,
......@@ -210,14 +208,9 @@ public class FlywayAutoConfiguration {
}
}
private void configureFlywayCallbacks(Flyway flyway, List<Callback> callbacks,
List<FlywayCallback> flywayCallbacks) {
if (!flywayCallbacks.isEmpty()) {
if (!callbacks.isEmpty()) {
throw new IllegalStateException("Found a mixture of Callback and FlywayCallback beans."
+ " One type must be used exclusively.");
}
flyway.setCallbacks(flywayCallbacks.toArray(new FlywayCallback[0]));
private void configureFlywayCallbacks(FluentConfiguration flyway, List<Callback> callbacks) {
if (!callbacks.isEmpty()) {
flyway.callbacks(callbacks.toArray(new Callback[0]));
}
}
......
......@@ -96,9 +96,10 @@ class FlywayPropertiesTests {
ignoreProperties(properties, "url", "user", "password", "enabled", "checkLocation", "createDataSource");
// High level object we can't set with properties
ignoreProperties(configuration, "classLoader", "dataSource", "resolvers", "callbacks");
ignoreProperties(configuration, "classLoader", "dataSource", "resolvers", "callbacks", "javaMigrations");
// Properties we don't want to expose
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames");
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames", "tablespace",
"oracleSqlplusWarn");
// Handled by the conversion service
ignoreProperties(configuration, "baselineVersionAsString", "encodingAsString", "locationsAsStrings",
"targetAsString");
......@@ -107,8 +108,6 @@ class FlywayPropertiesTests {
ignoreProperties(properties, "initSqls");
// Handled as dryRunOutput
ignoreProperties(configuration, "dryRunOutputAsFile", "dryRunOutputAsFileName");
// Deprecated
ignoreProperties(configuration, "errorHandlers", "errorHandlersAsClassNames");
List<String> configurationKeys = new ArrayList<>(configuration.keySet());
Collections.sort(configurationKeys);
List<String> propertiesKeys = new ArrayList<>(properties.keySet());
......
......@@ -60,7 +60,7 @@
<ehcache.version>2.10.6</ehcache.version>
<ehcache3.version>3.8.0</ehcache3.version>
<embedded-mongo.version>2.2.0</embedded-mongo.version>
<flyway.version>5.2.4</flyway.version>
<flyway.version>6.0.1</flyway.version>
<freemarker.version>2.3.28</freemarker.version>
<elasticsearch.version>6.8.2</elasticsearch.version>
<glassfish-el.version>3.0.2</glassfish-el.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment