Commit 5b2caa89 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge pull request #17997 from SammyVimes

* gh-17997:
  Polish "Upgrade to Flyway 6.0.1"
  Upgrade to Flyway 6.0.1

Closes gh-17997
parents 1e2f8959 0e2a131e
......@@ -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,9 +80,9 @@ 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")
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Flyway.class)
@Conditional(FlywayDataSourceCondition.class)
......@@ -113,7 +112,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 +121,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,
......@@ -168,6 +165,7 @@ public class FlywayAutoConfiguration {
map.from(properties.getConnectRetries()).to(configuration::connectRetries);
map.from(properties.getSchemas()).as(StringUtils::toStringArray).to(configuration::schemas);
map.from(properties.getTable()).to(configuration::table);
map.from(properties.getTablespace()).to(configuration::tablespace);
map.from(properties.getBaselineDescription()).to(configuration::baselineDescription);
map.from(properties.getBaselineVersion()).to(configuration::baselineVersion);
map.from(properties.getInstalledBy()).to(configuration::installedBy);
......@@ -200,6 +198,7 @@ public class FlywayAutoConfiguration {
map.from(properties.getErrorOverrides()).whenNonNull().to(configuration::errorOverrides);
map.from(properties.getLicenseKey()).whenNonNull().to(configuration::licenseKey);
map.from(properties.getOracleSqlplus()).whenNonNull().to(configuration::oracleSqlplus);
map.from(properties.getOracleSqlplusWarn()).whenNonNull().to(configuration::oracleSqlplusWarn);
map.from(properties.getStream()).whenNonNull().to(configuration::stream);
map.from(properties.getUndoSqlMigrationPrefix()).whenNonNull().to(configuration::undoSqlMigrationPrefix);
}
......@@ -210,14 +209,9 @@ public class FlywayAutoConfiguration {
}
}
private void configureFlywayCallbacks(Flyway flyway, List<Callback> callbacks,
List<FlywayCallback> flywayCallbacks) {
if (!flywayCallbacks.isEmpty()) {
private void configureFlywayCallbacks(FluentConfiguration flyway, List<Callback> callbacks) {
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]));
flyway.callbacks(callbacks.toArray(new Callback[0]));
}
}
......
......@@ -74,6 +74,13 @@ public class FlywayProperties {
*/
private String table = "flyway_schema_history";
/**
* Tablespace in which the schema history table is created. Ignored when using a
* database that does not support tablespaces. Defaults to the default tablespace of
* the connection used by Flyway.
*/
private String tablespace;
/**
* Description to tag an existing schema with when applying a baseline.
*/
......@@ -252,6 +259,12 @@ public class FlywayProperties {
*/
private Boolean oracleSqlplus;
/**
* Whether to issue a warning rather than an error when a not-yet-supported Oracle
* SQL*Plus statement is encountered. Requires Flyway Pro or Flyway Enterprise.
*/
private Boolean oracleSqlplusWarn;
/**
* Whether to stream SQL migrations when executing them. Requires Flyway Pro or Flyway
* Enterprise.
......@@ -319,6 +332,14 @@ public class FlywayProperties {
this.table = table;
}
public String getTablespace() {
return this.tablespace;
}
public void setTablespace(String tablespace) {
this.tablespace = tablespace;
}
public String getBaselineDescription() {
return this.baselineDescription;
}
......@@ -595,6 +616,14 @@ public class FlywayProperties {
this.oracleSqlplus = oracleSqlplus;
}
public Boolean getOracleSqlplusWarn() {
return this.oracleSqlplusWarn;
}
public void setOracleSqlplusWarn(Boolean oracleSqlplusWarn) {
this.oracleSqlplusWarn = oracleSqlplusWarn;
}
public Boolean getStream() {
return this.stream;
}
......
......@@ -96,7 +96,7 @@ 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, "callbacks", "classLoader", "dataSource", "javaMigrations", "resolvers");
// Properties we don't want to expose
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames");
// Handled by the conversion service
......@@ -107,8 +107,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