Upgrade to Flyway 6.5.0 and support createSchemas
See gh-22120
This commit is contained in:
parent
f6400e95ee
commit
6c29b29bd5
|
|
@ -178,6 +178,7 @@ public class FlywayAutoConfiguration {
|
|||
// No method reference for compatibility with Flyway 5.x
|
||||
map.from(properties.getDefaultSchema()).to((schema) -> configuration.defaultSchema(schema));
|
||||
map.from(properties.getSchemas()).as(StringUtils::toStringArray).to(configuration::schemas);
|
||||
configureCreateSchemas(configuration, properties.isCreateSchemas());
|
||||
map.from(properties.getTable()).to(configuration::table);
|
||||
// No method reference for compatibility with Flyway 5.x
|
||||
map.from(properties.getTablespace()).whenNonNull().to((tablespace) -> configuration.tablespace(tablespace));
|
||||
|
|
@ -221,6 +222,15 @@ public class FlywayAutoConfiguration {
|
|||
map.from(properties.getUndoSqlMigrationPrefix()).whenNonNull().to(configuration::undoSqlMigrationPrefix);
|
||||
}
|
||||
|
||||
private void configureCreateSchemas(FluentConfiguration configuration, boolean createSchemas) {
|
||||
try {
|
||||
configuration.createSchemas(createSchemas);
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
// Flyway < 6.5
|
||||
}
|
||||
}
|
||||
|
||||
private void configureValidateMigrationNaming(FluentConfiguration configuration,
|
||||
boolean validateMigrationNaming) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ public class FlywayProperties {
|
|||
*/
|
||||
private List<String> schemas = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Whether Flyway should attempt to create the schemas specified in the schemas
|
||||
* property.
|
||||
*/
|
||||
private boolean createSchemas = true;
|
||||
|
||||
/**
|
||||
* Name of the schema history table that will be used by Flyway.
|
||||
*/
|
||||
|
|
@ -343,6 +349,14 @@ public class FlywayProperties {
|
|||
this.schemas = schemas;
|
||||
}
|
||||
|
||||
public boolean isCreateSchemas() {
|
||||
return this.createSchemas;
|
||||
}
|
||||
|
||||
public void setCreateSchemas(boolean createSchemas) {
|
||||
this.createSchemas = createSchemas;
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class FlywayPropertiesTests {
|
|||
assertThat(properties.getConnectRetries()).isEqualTo(configuration.getConnectRetries());
|
||||
assertThat(properties.getDefaultSchema()).isEqualTo(configuration.getDefaultSchema());
|
||||
assertThat(properties.getSchemas()).isEqualTo(Arrays.asList(configuration.getSchemas()));
|
||||
assertThat(properties.isCreateSchemas()).isEqualTo(configuration.getCreateSchemas());
|
||||
assertThat(properties.getTable()).isEqualTo(configuration.getTable());
|
||||
assertThat(properties.getBaselineDescription()).isEqualTo(configuration.getBaselineDescription());
|
||||
assertThat(MigrationVersion.fromVersion(properties.getBaselineVersion()))
|
||||
|
|
@ -98,7 +99,8 @@ class FlywayPropertiesTests {
|
|||
ignoreProperties(properties, "url", "user", "password", "enabled", "checkLocation", "createDataSource");
|
||||
|
||||
// High level object we can't set with properties
|
||||
ignoreProperties(configuration, "callbacks", "classLoader", "dataSource", "javaMigrations", "resolvers");
|
||||
ignoreProperties(configuration, "callbacks", "classLoader", "dataSource", "javaMigrations",
|
||||
"javaMigrationClassProvider", "resourceProvider", "resolvers");
|
||||
// Properties we don't want to expose
|
||||
ignoreProperties(configuration, "resolversAsClassNames", "callbacksAsClassNames");
|
||||
// Handled by the conversion service
|
||||
|
|
@ -109,6 +111,8 @@ class FlywayPropertiesTests {
|
|||
ignoreProperties(properties, "initSqls");
|
||||
// Handled as dryRunOutput
|
||||
ignoreProperties(configuration, "dryRunOutputAsFile", "dryRunOutputAsFileName");
|
||||
// Handled as createSchemas
|
||||
ignoreProperties(configuration, "shouldCreateSchemas");
|
||||
List<String> configurationKeys = new ArrayList<>(configuration.keySet());
|
||||
Collections.sort(configurationKeys);
|
||||
List<String> propertiesKeys = new ArrayList<>(properties.keySet());
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ bom {
|
|||
]
|
||||
}
|
||||
}
|
||||
library("Flyway", "6.4.4") {
|
||||
library("Flyway", "6.5.0") {
|
||||
group("org.flywaydb") {
|
||||
modules = [
|
||||
"flyway-core"
|
||||
|
|
|
|||
Loading…
Reference in New Issue