Polish "Upgrade to Flyway 7.9.2"

See gh-26456
pull/26903/head
Stephane Nicoll 4 years ago
parent e6236b76bb
commit 05acfaa690

@ -258,7 +258,7 @@ public class FlywayAutoConfiguration {
.to((ignoreMigrationPatterns) -> configuration .to((ignoreMigrationPatterns) -> configuration
.ignoreMigrationPatterns(ignoreMigrationPatterns.toArray(new String[0]))); .ignoreMigrationPatterns(ignoreMigrationPatterns.toArray(new String[0])));
// No method reference for compatibility with Flyway version < 7.9 // No method reference for compatibility with Flyway version < 7.9
map.from(properties.getDetectEncoding()).whenNonNull() map.from(properties.getDetectEncoding())
.to((detectEncoding) -> configuration.detectEncoding(detectEncoding)); .to((detectEncoding) -> configuration.detectEncoding(detectEncoding));
} }

@ -53,8 +53,7 @@ public class FlywayProperties {
private boolean checkLocation = true; private boolean checkLocation = true;
/** /**
* Whether Flyway should fail if a location specified in the flyway.locations option * Whether to fail if a location of migration scripts doesn't exist.
* doesn't exist.
*/ */
private boolean failOnMissingLocations; private boolean failOnMissingLocations;
@ -368,8 +367,8 @@ public class FlywayProperties {
private List<String> ignoreMigrationPatterns; private List<String> ignoreMigrationPatterns;
/** /**
* Whether Flyway should try to automatically detect SQL migration file encoding. * Whether to attempt to automatically detect SQL migration file encoding. Requires
* Requires Flyway Teams. * Flyway Teams.
*/ */
private Boolean detectEncoding; private Boolean detectEncoding;

@ -288,6 +288,7 @@ class FlywayAutoConfigurationTests {
} }
@Test @Test
@Deprecated
void checkLocationsAllMissing() { void checkLocationsAllMissing() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2") .withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2")
@ -299,6 +300,7 @@ class FlywayAutoConfigurationTests {
} }
@Test @Test
@Deprecated
void checkLocationsAllExist() { void checkLocationsAllExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration") .withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration")
@ -306,6 +308,7 @@ class FlywayAutoConfigurationTests {
} }
@Test @Test
@Deprecated
void checkLocationsAllExistWithImplicitClasspathPrefix() { void checkLocationsAllExistWithImplicitClasspathPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:db/changelog,db/migration") .withPropertyValues("spring.flyway.locations:db/changelog,db/migration")
@ -313,12 +316,53 @@ class FlywayAutoConfigurationTests {
} }
@Test @Test
@Deprecated
void checkLocationsAllExistWithFilesystemPrefix() { void checkLocationsAllExistWithFilesystemPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration") .withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration")
.run((context) -> assertThat(context).hasNotFailed()); .run((context) -> assertThat(context).hasNotFailed());
} }
@Test
void failOnMissingLocationsAllMissing() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.check-location=false",
"spring.flyway.fail-on-missing-locations=true")
.withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2")
.run((context) -> {
assertThat(context).hasFailed();
assertThat(context).getFailure().isInstanceOf(BeanCreationException.class);
assertThat(context).getFailure().hasMessageContaining("Unable to resolve location");
});
}
@Test
void failOnMissingLocationsAllExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.check-location=false",
"spring.flyway.fail-on-missing-locations=true")
.withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration")
.run((context) -> assertThat(context).hasNotFailed());
}
@Test
void failOnMissingLocationsAllExistWithImplicitClasspathPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.check-location=false",
"spring.flyway.fail-on-missing-locations=true")
.withPropertyValues("spring.flyway.locations:db/changelog,db/migration")
.run((context) -> assertThat(context).hasNotFailed());
}
@Test
void failOnMissingLocationsAllExistWithFilesystemPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.check-location=false",
"spring.flyway.fail-on-missing-locations=true")
.withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration")
.run((context) -> assertThat(context).hasNotFailed());
}
@Test @Test
void customFlywayMigrationStrategy() { void customFlywayMigrationStrategy() {
this.contextRunner this.contextRunner

Loading…
Cancel
Save