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