Commit 7d2e25f6 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.5.x' into 2.0.x

parents ee0de14e 7865233b
...@@ -176,13 +176,17 @@ public class FlywayAutoConfiguration { ...@@ -176,13 +176,17 @@ public class FlywayAutoConfiguration {
private boolean hasAtLeastOneLocation(String... locations) { private boolean hasAtLeastOneLocation(String... locations) {
for (String location : locations) { for (String location : locations) {
if (this.resourceLoader.getResource(location).exists()) { if (this.resourceLoader.getResource(normalizePrefix(location)).exists()) {
return true; return true;
} }
} }
return false; return false;
} }
private String normalizePrefix(String location) {
return location.replace("filesystem:", "file:");
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) { public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {
......
...@@ -181,7 +181,7 @@ public class FlywayAutoConfigurationTests { ...@@ -181,7 +181,7 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void changeLogDoesNotExist() { public void changeLogDoesNotExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:file:no-such-dir") .withPropertyValues("spring.flyway.locations:filesystem:no-such-dir")
.run((context) -> { .run((context) -> {
assertThat(context).hasFailed(); assertThat(context).hasFailed();
assertThat(context).getFailure() assertThat(context).getFailure()
...@@ -218,6 +218,14 @@ public class FlywayAutoConfigurationTests { ...@@ -218,6 +218,14 @@ public class FlywayAutoConfigurationTests {
.run((context) -> assertThat(context).hasNotFailed()); .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 @Test
public void customFlywayMigrationStrategy() { public void customFlywayMigrationStrategy() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
......
...@@ -2205,8 +2205,17 @@ To automatically run Flyway database migrations on startup, add the ...@@ -2205,8 +2205,17 @@ To automatically run Flyway database migrations on startup, add the
The migrations are scripts in the form `V<VERSION>__<NAME>.sql` (with `<VERSION>` an The migrations are scripts in the form `V<VERSION>__<NAME>.sql` (with `<VERSION>` an
underscore-separated version, such as '`1`' or '`2_1`'). By default, they are in a folder underscore-separated version, such as '`1`' or '`2_1`'). By default, they are in a folder
called `classpath:db/migration`, but you can modify that location by setting called `classpath:db/migration`, but you can modify that location by setting
`spring.flyway.locations`. You can also add a special `{vendor}` placeholder to use `spring.flyway.locations`. This is a comma-separated list of one or more `classpath:`
vendor-specific scripts. Assume the following: or `filesystem:` locations. For example, the following configuration would search for
scripts in both the default classpath location and the `/opt/migration` directory:
[source,properties,indent=0]
----
spring.flyway.locations=classpath:db/migration,filesystem:/opt/migration
----
You can also add a special `{vendor}` placeholder to use vendor-specific scripts. Assume
the following:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment