Skip to content

Commit 7d2e25f

Browse files
committed
Merge branch '1.5.x' into 2.0.x
2 parents ee0de14 + 7865233 commit 7d2e25f

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ private void checkLocationExists(String... locations) {
176176

177177
private boolean hasAtLeastOneLocation(String... locations) {
178178
for (String location : locations) {
179-
if (this.resourceLoader.getResource(location).exists()) {
179+
if (this.resourceLoader.getResource(normalizePrefix(location)).exists()) {
180180
return true;
181181
}
182182
}
183183
return false;
184184
}
185185

186+
private String normalizePrefix(String location) {
187+
return location.replace("filesystem:", "file:");
188+
}
189+
186190
@Bean
187191
@ConditionalOnMissingBean
188192
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void overrideSchemas() {
181181
@Test
182182
public void changeLogDoesNotExist() {
183183
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
184-
.withPropertyValues("spring.flyway.locations:file:no-such-dir")
184+
.withPropertyValues("spring.flyway.locations:filesystem:no-such-dir")
185185
.run((context) -> {
186186
assertThat(context).hasFailed();
187187
assertThat(context).getFailure()
@@ -218,6 +218,14 @@ public void checkLocationsAllExistWithImplicitClasspathPrefix() {
218218
.run((context) -> assertThat(context).hasNotFailed());
219219
}
220220

221+
@Test
222+
public void checkLocationsAllExistWithFilesystemPrefix() {
223+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
224+
.withPropertyValues(
225+
"spring.flyway.locations:filesystem:src/test/resources/db/migration")
226+
.run((context) -> assertThat(context).hasNotFailed());
227+
}
228+
221229
@Test
222230
public void customFlywayMigrationStrategy() {
223231
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,8 +2205,17 @@ To automatically run Flyway database migrations on startup, add the
22052205
The migrations are scripts in the form `V<VERSION>__<NAME>.sql` (with `<VERSION>` an
22062206
underscore-separated version, such as '`1`' or '`2_1`'). By default, they are in a folder
22072207
called `classpath:db/migration`, but you can modify that location by setting
2208-
`spring.flyway.locations`. You can also add a special `{vendor}` placeholder to use
2209-
vendor-specific scripts. Assume the following:
2208+
`spring.flyway.locations`. This is a comma-separated list of one or more `classpath:`
2209+
or `filesystem:` locations. For example, the following configuration would search for
2210+
scripts in both the default classpath location and the `/opt/migration` directory:
2211+
2212+
[source,properties,indent=0]
2213+
----
2214+
spring.flyway.locations=classpath:db/migration,filesystem:/opt/migration
2215+
----
2216+
2217+
You can also add a special `{vendor}` placeholder to use vendor-specific scripts. Assume
2218+
the following:
22102219

22112220
[source,properties,indent=0]
22122221
----

0 commit comments

Comments
 (0)