From 0e2a131e5d87dc2e51905843394348e1261ea3e3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 29 Aug 2019 19:58:26 +0100 Subject: [PATCH] Polish "Upgrade to Flyway 6.0.1" See gh-17997 --- .../flyway/FlywayAutoConfiguration.java | 3 +- .../flyway/FlywayProperties.java | 29 +++++++++++++++++++ .../flyway/FlywayAutoConfigurationTests.java | 12 +++++++- .../flyway/FlywayPropertiesTests.java | 5 ++-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 9e93303be9..b2a684af5c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -83,7 +83,6 @@ import org.springframework.util.StringUtils; * @author Semyon Danilov * @since 1.1.0 */ -@SuppressWarnings("deprecation") @Configuration(proxyBeanMethods = false) @ConditionalOnClass(Flyway.class) @Conditional(FlywayDataSourceCondition.class) @@ -166,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); @@ -198,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); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index a4c6844e5e..0ece0e045e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -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; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index fdb8ed92b5..1a4e0cd4c4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -70,7 +70,6 @@ import static org.mockito.Mockito.mock; * @author Dominic Gunn * @author András Deák */ -@SuppressWarnings("deprecation") class FlywayAutoConfigurationTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner() @@ -411,6 +410,17 @@ class FlywayAutoConfigurationTests { }); } + @Test + void oracleSqlplusWarnIsCorrectlyMapped() { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("spring.flyway.oracle-sqlplus-warn=true").run((context) -> { + assertThat(context).hasFailed(); + Throwable failure = context.getStartupFailure(); + assertThat(failure).hasRootCauseInstanceOf(FlywayProUpgradeRequiredException.class); + assertThat(failure).hasMessageContaining(" oracle.sqlplusWarn "); + }); + } + @Test void streamIsCorrectlyMapped() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java index 672f4d388c..b200c6cf3f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java @@ -96,10 +96,9 @@ 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", "javaMigrations"); + ignoreProperties(configuration, "callbacks", "classLoader", "dataSource", "javaMigrations", "resolvers"); // Properties we don't want to expose - ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames", "tablespace", - "oracleSqlplusWarn"); + ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames"); // Handled by the conversion service ignoreProperties(configuration, "baselineVersionAsString", "encodingAsString", "locationsAsStrings", "targetAsString");