Merge branch '2.0.x'
This commit is contained in:
@@ -195,13 +195,17 @@ public class FlywayAutoConfiguration {
|
||||
|
||||
private boolean hasAtLeastOneLocation(String... locations) {
|
||||
for (String location : locations) {
|
||||
if (this.resourceLoader.getResource(location).exists()) {
|
||||
if (this.resourceLoader.getResource(normalizePrefix(location)).exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String normalizePrefix(String location) {
|
||||
return location.replace("filesystem:", "file:");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {
|
||||
|
||||
@@ -189,7 +189,7 @@ public class FlywayAutoConfigurationTests {
|
||||
@Test
|
||||
public void changeLogDoesNotExist() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.flyway.locations:file:no-such-dir")
|
||||
.withPropertyValues("spring.flyway.locations:filesystem:no-such-dir")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure()
|
||||
@@ -226,6 +226,14 @@ public class FlywayAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkLocationsAllExistWithFilesystemPrefix() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"spring.flyway.locations:filesystem:src/test/resources/db/migration")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customFlywayMigrationStrategy() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
|
||||
|
||||
Reference in New Issue
Block a user