Upgrade to Flyway 10.15.0

Closes gh-41217
This commit is contained in:
Andy Wilkinson 2024-06-24 14:08:39 +01:00
parent 6bdba8e69e
commit 5920b27b57
6 changed files with 81 additions and 1 deletions

View File

@ -302,6 +302,8 @@ public class FlywayAutoConfiguration {
.to((suffix) -> configuration.scriptPlaceholderSuffix(suffix));
configureExecuteInTransaction(configuration, properties, map);
map.from(properties::getLoggers).to((loggers) -> configuration.loggers(loggers));
map.from(properties::getCommunityDbSupportEnabled)
.to((communityDbSupportEnabled) -> configuration.communityDBSupportEnabled(communityDbSupportEnabled));
// Flyway Teams properties
map.from(properties.getBatch()).to((batch) -> configuration.batch(batch));
map.from(properties.getDryRunOutput()).to((dryRunOutput) -> configuration.dryRunOutput(dryRunOutput));

View File

@ -330,6 +330,11 @@ public class FlywayProperties {
*/
private Boolean detectEncoding;
/**
* Whether to enable community database support.
*/
private Boolean communityDbSupportEnabled;
private final Oracle oracle = new Oracle();
private final Postgresql postgresql = new Postgresql();
@ -823,6 +828,14 @@ public class FlywayProperties {
this.detectEncoding = detectEncoding;
}
public Boolean getCommunityDbSupportEnabled() {
return this.communityDbSupportEnabled;
}
public void setCommunityDbSupportEnabled(Boolean communityDbSupportEnabled) {
this.communityDbSupportEnabled = communityDbSupportEnabled;
}
public Oracle getOracle() {
return this.oracle;
}

View File

@ -1346,6 +1346,9 @@
"level": "error",
"reason": "Removed in Flyway 10"
}
},{
"name": "spring.flyway.community-db-support-enabled",
"defaultValue": false
},
{
"name": "spring.flyway.dry-run-output",

View File

@ -0,0 +1,54 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.flyway;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link FlywayAutoConfiguration} with Flyway 10.0.
*
* @author Andy Wilkinson
*/
@ClassPathExclusions({ "flyway-core-*.jar", "flyway-sqlserver-*.jar" })
@ClassPathOverrides({ "org.flywaydb:flyway-core:10.0.0", "com.h2database:h2:2.1.210" })
class Flyway100AutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class))
.withPropertyValues("spring.datasource.generate-unique-name=true");
@Test
void defaultFlyway() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);
assertThat(flyway.getConfiguration().getLocations())
.containsExactly(new Location("classpath:db/migration"));
});
}
}

View File

@ -93,6 +93,7 @@ class FlywayPropertiesTests {
assertThat(properties.getScriptPlaceholderPrefix()).isEqualTo(configuration.getScriptPlaceholderPrefix());
assertThat(properties.getScriptPlaceholderSuffix()).isEqualTo(configuration.getScriptPlaceholderSuffix());
assertThat(properties.isExecuteInTransaction()).isEqualTo(configuration.isExecuteInTransaction());
assertThat(properties.getCommunityDbSupportEnabled()).isNull();
}
@Test
@ -140,6 +141,7 @@ class FlywayPropertiesTests {
ignoreProperties(configuration, "failOnMissingTarget");
// Properties managed by a proprietary extension
ignoreProperties(configuration, "cherryPick");
aliasProperty(configuration, "communityDBSupportEnabled", "communityDbSupportEnabled");
List<String> configurationKeys = new ArrayList<>(configuration.keySet());
Collections.sort(configurationKeys);
List<String> propertiesKeys = new ArrayList<>(properties.keySet());
@ -154,6 +156,12 @@ class FlywayPropertiesTests {
}
}
private void aliasProperty(Map<String, PropertyDescriptor> index, String originalName, String alias) {
PropertyDescriptor descriptor = index.remove(originalName);
assertThat(descriptor).describedAs("Property to alias should be present " + originalName).isNotNull();
index.put(alias, descriptor);
}
private Map<String, PropertyDescriptor> indexProperties(BeanWrapper beanWrapper) {
Map<String, PropertyDescriptor> descriptor = new HashMap<>();
for (PropertyDescriptor propertyDescriptor : beanWrapper.getPropertyDescriptors()) {

View File

@ -373,7 +373,7 @@ bom {
releaseNotes("https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-{version}.html")
}
}
library("Flyway", "10.10.0") {
library("Flyway", "10.15.0") {
group("org.flywaydb") {
modules = [
"flyway-commandline",