Polish "Upgrade to Flyway 6.2.0"

See gh-19894
pull/19948/head
Stephane Nicoll 5 years ago
parent 0ae075efd5
commit ed14173865

@ -206,6 +206,7 @@ public class FlywayAutoConfiguration {
map.from(properties.isOutOfOrder()).to(configuration::outOfOrder);
map.from(properties.isSkipDefaultCallbacks()).to(configuration::skipDefaultCallbacks);
map.from(properties.isSkipDefaultResolvers()).to(configuration::skipDefaultResolvers);
configureValidateMigrationNaming(configuration, properties.isValidateMigrationNaming());
map.from(properties.isValidateOnMigrate()).to(configuration::validateOnMigrate);
// Pro properties
map.from(properties.getBatch()).whenNonNull().to(configuration::batch);
@ -218,8 +219,16 @@ public class FlywayAutoConfiguration {
.to((oracleSqlplusWarn) -> configuration.oracleSqlplusWarn(oracleSqlplusWarn));
map.from(properties.getStream()).whenNonNull().to(configuration::stream);
map.from(properties.getUndoSqlMigrationPrefix()).whenNonNull().to(configuration::undoSqlMigrationPrefix);
// No method reference for compatibility with Flyway version < 6.2
configureValidateMigrationNaming(configuration, properties.isValidateMigrationNaming());
}
private void configureValidateMigrationNaming(FluentConfiguration configuration,
boolean validateMigrationNaming) {
try {
configuration.validateMigrationNaming(validateMigrationNaming);
}
catch (NoSuchMethodError ex) {
// Flyway < 6.2
}
}
private void configureCallbacks(FluentConfiguration configuration, List<Callback> callbacks) {
@ -245,15 +254,6 @@ public class FlywayAutoConfiguration {
}
}
private void configureValidateMigrationNaming(FluentConfiguration flyway, boolean isValidateMigrationNaming) {
try {
flyway.validateMigrationNaming(isValidateMigrationNaming);
}
catch (NoSuchMethodError ex) {
// Flyway < v6.2
}
}
private String getProperty(Supplier<String> property, Supplier<String> defaultValue) {
String value = property.get();
return (value != null) ? value : defaultValue.get();

@ -209,12 +209,6 @@ public class FlywayProperties {
*/
private boolean ignoreFutureMigrations = true;
/**
* Whether to validate migrations and callbacks whose scripts do not obey the correct
* naming convention.
*/
private boolean validateMigrationNaming = false;
/**
* Whether to allow mixing transactional and non-transactional statements within the
* same migration.
@ -236,6 +230,12 @@ public class FlywayProperties {
*/
private boolean skipDefaultResolvers;
/**
* Whether to validate migrations and callbacks whose scripts do not obey the correct
* naming convention.
*/
private boolean validateMigrationNaming = false;
/**
* Whether to automatically call validate when performing a migration.
*/
@ -555,14 +555,6 @@ public class FlywayProperties {
this.ignoreFutureMigrations = ignoreFutureMigrations;
}
public boolean isValidateMigrationNaming() {
return this.validateMigrationNaming;
}
public void setValidateMigrationNaming(boolean validateMigrationNaming) {
this.validateMigrationNaming = validateMigrationNaming;
}
public boolean isMixed() {
return this.mixed;
}
@ -595,6 +587,14 @@ public class FlywayProperties {
this.skipDefaultResolvers = skipDefaultResolvers;
}
public boolean isValidateMigrationNaming() {
return this.validateMigrationNaming;
}
public void setValidateMigrationNaming(boolean validateMigrationNaming) {
this.validateMigrationNaming = validateMigrationNaming;
}
public boolean isValidateOnMigrate() {
return this.validateOnMigrate;
}

@ -80,11 +80,11 @@ class FlywayPropertiesTests {
assertThat(configuration.isIgnoreIgnoredMigrations()).isEqualTo(properties.isIgnoreIgnoredMigrations());
assertThat(configuration.isIgnorePendingMigrations()).isEqualTo(properties.isIgnorePendingMigrations());
assertThat(configuration.isIgnoreFutureMigrations()).isEqualTo(properties.isIgnoreFutureMigrations());
assertThat(configuration.isValidateMigrationNaming()).isEqualTo(properties.isValidateMigrationNaming());
assertThat(configuration.isMixed()).isEqualTo(properties.isMixed());
assertThat(configuration.isOutOfOrder()).isEqualTo(properties.isOutOfOrder());
assertThat(configuration.isSkipDefaultCallbacks()).isEqualTo(properties.isSkipDefaultCallbacks());
assertThat(configuration.isSkipDefaultResolvers()).isEqualTo(properties.isSkipDefaultResolvers());
assertThat(configuration.isValidateMigrationNaming()).isEqualTo(properties.isValidateMigrationNaming());
assertThat(configuration.isValidateOnMigrate()).isEqualTo(properties.isValidateOnMigrate());
}

Loading…
Cancel
Save