Browse Source

Merge branch '1.5.x' into 2.0.x

pull/14003/head
Stephane Nicoll 8 years ago
parent
commit
7d2e25f6f8
  1. 6
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
  2. 10
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
  3. 13
      spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

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

@ -176,13 +176,17 @@ public class FlywayAutoConfiguration { @@ -176,13 +176,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) {

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

@ -181,7 +181,7 @@ public class FlywayAutoConfigurationTests { @@ -181,7 +181,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()
@ -218,6 +218,14 @@ public class FlywayAutoConfigurationTests { @@ -218,6 +218,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,

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

@ -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
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
`spring.flyway.locations`. You can also add a special `{vendor}` placeholder to use
vendor-specific scripts. Assume the following:
`spring.flyway.locations`. This is a comma-separated list of one or more `classpath:`
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]
----

Loading…
Cancel
Save