Merge branch '2.0.x'
This commit is contained in:
commit
dcd230fc00
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -2207,8 +2207,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…
Reference in New Issue