Fix Flyway filesystem prefix location check
Co-authored-by: Andy Bell <andyrbell@gmail.com> Closes gh-13863
This commit is contained in:
@@ -117,13 +117,17 @@ public class FlywayAutoConfiguration {
|
||||
|
||||
private boolean hasAtLeastOneLocation() {
|
||||
for (String location : this.properties.getLocations()) {
|
||||
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
|
||||
@ConfigurationProperties(prefix = "flyway")
|
||||
public Flyway flyway() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -153,7 +153,7 @@ public class FlywayAutoConfigurationTests {
|
||||
@Test
|
||||
public void changeLogDoesNotExist() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"flyway.locations:file:no-such-dir");
|
||||
"flyway.locations:filesystem:no-such-dir");
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
@@ -192,6 +192,16 @@ public class FlywayAutoConfigurationTests {
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkLocationsAllExistWithImplicitFilesystemPrefix() {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"flyway.locations:filesystem:src/test/resources/db/migration",
|
||||
"flyway.check-location:true");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customFlywayMigrationStrategy() throws Exception {
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
|
||||
Reference in New Issue
Block a user