Upgrade to Flyway 7.15.0

Closes gh-28049
pull/28064/head
Andy Wilkinson 3 years ago
parent 5857bcccc6
commit 7924d1fc18

@ -180,6 +180,9 @@ public class FlywayAutoConfiguration {
map.from(locations).to(configuration::locations);
map.from(properties.getEncoding()).to(configuration::encoding);
map.from(properties.getConnectRetries()).to(configuration::connectRetries);
// No method reference for compatibility with Flyway < 7.15
map.from(properties.getConnectRetriesInterval())
.to((interval) -> configuration.connectRetriesInterval((int) interval.getSeconds()));
// No method reference for compatibility with Flyway 6.x
map.from(properties.getLockRetryCount())
.to((lockRetryCount) -> configuration.lockRetryCount(lockRetryCount));
@ -220,6 +223,10 @@ public class FlywayAutoConfiguration {
map.from(properties.getInitSqls()).whenNot(CollectionUtils::isEmpty)
.as((initSqls) -> StringUtils.collectionToDelimitedString(initSqls, "\n"))
.to(configuration::initSql);
map.from(properties.getScriptPlaceholderPrefix())
.to((prefix) -> configuration.scriptPlaceholderPrefix(prefix));
map.from(properties.getScriptPlaceholderPrefix())
.to((suffix) -> configuration.scriptPlaceholderPrefix(suffix));
// Pro properties
map.from(properties.getBatch()).to(configuration::batch);
map.from(properties.getDryRunOutput()).to(configuration::dryRunOutput);

@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.flyway;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -27,6 +29,7 @@ import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.convert.DurationUnit;
/**
* Configuration properties for Flyway database migrations.
@ -73,6 +76,13 @@ public class FlywayProperties {
*/
private int connectRetries;
/**
* Maximum time between retries when attempting to connect to the database. If a
* duration suffix is not specified, seconds will be used.
*/
@DurationUnit(ChronoUnit.SECONDS)
private Duration connectRetriesInterval;
/**
* Maximum number of retries when trying to obtain a lock.
*/
@ -365,6 +375,16 @@ public class FlywayProperties {
*/
private String stateScriptPrefix;
/**
* Prefix of placeholders in migration scripts.
*/
private String scriptPlaceholderPrefix;
/**
* Suffix of placeholders in migration scripts.
*/
private String scriptPlaceholderSuffix;
public boolean isEnabled() {
return this.enabled;
}
@ -417,6 +437,14 @@ public class FlywayProperties {
this.connectRetries = connectRetries;
}
public Duration getConnectRetriesInterval() {
return this.connectRetriesInterval;
}
public void setConnectRetriesInterval(Duration connectRetriesInterval) {
this.connectRetriesInterval = connectRetriesInterval;
}
public Integer getLockRetryCount() {
return this.lockRetryCount;
}
@ -868,4 +896,20 @@ public class FlywayProperties {
this.stateScriptPrefix = stateScriptPrefix;
}
public String getScriptPlaceholderPrefix() {
return this.scriptPlaceholderPrefix;
}
public void setScriptPlaceholderPrefix(String scriptPlaceholderPrefix) {
this.scriptPlaceholderPrefix = scriptPlaceholderPrefix;
}
public String getScriptPlaceholderSuffix() {
return this.scriptPlaceholderSuffix;
}
public void setScriptPlaceholderSuffix(String scriptPlaceholderSuffix) {
this.scriptPlaceholderSuffix = scriptPlaceholderSuffix;
}
}

@ -860,6 +860,10 @@
"http://localhost:9200"
]
},
{
"name": "spring.flyway.connect-retries-interval",
"defaultValue": 120
},
{
"name": "spring.flyway.dry-run-output",
"type": "java.io.OutputStream",
@ -887,6 +891,14 @@
"name": "spring.flyway.lock-retry-count",
"defaultValue": 50
},
{
"name": "spring.flyway.script-placeholder-prefix",
"defaultValue": "FP__"
},
{
"name": "spring.flyway.script-placeholder-suffix",
"defaultValue": "__"
},
{
"name": "spring.flyway.sql-migration-suffix",
"type": "java.lang.String",

@ -53,6 +53,9 @@ class FlywayPropertiesTests {
.isEqualTo(configuration.getLocations());
assertThat(properties.getEncoding()).isEqualTo(configuration.getEncoding());
assertThat(properties.getConnectRetries()).isEqualTo(configuration.getConnectRetries());
// Can't assert connect retries interval as it is new in Flyway 7.15
// Asserting hard-coded value in the metadata instead
assertThat(configuration.getConnectRetriesInterval()).isEqualTo(120);
// Can't assert lock retry count default as it is new in Flyway 7.1
// Asserting hard-coded value in the metadata instead
assertThat(configuration.getLockRetryCount()).isEqualTo(50);
@ -93,6 +96,8 @@ class FlywayPropertiesTests {
assertThat(configuration.isValidateMigrationNaming()).isEqualTo(properties.isValidateMigrationNaming());
assertThat(configuration.isValidateOnMigrate()).isEqualTo(properties.isValidateOnMigrate());
assertThat(properties.getDetectEncoding()).isNull();
assertThat(configuration.getScriptPlaceholderPrefix()).isEqualTo("FP__");
assertThat(configuration.getScriptPlaceholderSuffix()).isEqualTo("__");
}
@Test
@ -108,7 +113,7 @@ class FlywayPropertiesTests {
ignoreProperties(configuration, "callbacks", "classLoader", "dataSource", "javaMigrations",
"javaMigrationClassProvider", "resourceProvider", "resolvers");
// Properties we don't want to expose
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames", "apiExtensions");
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames", "apiExtensions", "loggers");
// Handled by the conversion service
ignoreProperties(configuration, "baselineVersionAsString", "encodingAsString", "locationsAsStrings",
"targetAsString");

@ -309,7 +309,7 @@ bom {
]
}
}
library("Flyway", "7.13.0") {
library("Flyway", "7.15.0") {
group("org.flywaydb") {
modules = [
"flyway-core"

Loading…
Cancel
Save