mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Allow indexed access of flyway.locations
This commit allows to use the `flyway.locations` in an indexed fashion (i.e. typically in YAML configuration). See gh-4973
This commit is contained in:
parent
5ef6903690
commit
a749855cb5
@ -114,6 +114,8 @@ public class FlywayAutoConfiguration {
|
|||||||
else {
|
else {
|
||||||
flyway.setDataSource(this.dataSource);
|
flyway.setDataSource(this.dataSource);
|
||||||
}
|
}
|
||||||
|
//Explicitly set locations because the getter doesn't return a mutable value
|
||||||
|
flyway.setLocations(this.properties.getLocations().toArray(new String[0]));
|
||||||
return flyway;
|
return flyway;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.boot.autoconfigure.flyway;
|
package org.springframework.boot.autoconfigure.flyway;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,7 +40,7 @@ public class FlywayProperties {
|
|||||||
/**
|
/**
|
||||||
* Locations of migrations scripts.
|
* Locations of migrations scripts.
|
||||||
*/
|
*/
|
||||||
private List<String> locations = Arrays.asList("db/migration");
|
private List<String> locations = new ArrayList<String>(Arrays.asList("db/migration"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that migration scripts location exists.
|
* Check that migration scripts location exists.
|
||||||
|
@ -104,8 +104,8 @@ public class FlywayAutoConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void overrideLocations() throws Exception {
|
public void overrideLocations() throws Exception {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context, "flyway.locations[0]:classpath:db/changelog",
|
||||||
"flyway.locations:classpath:db/changelog,classpath:db/migration");
|
"flyway.locations[1]:classpath:db/migration");
|
||||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||||
FlywayAutoConfiguration.class,
|
FlywayAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class);
|
PropertyPlaceholderAutoConfiguration.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user