Commit a749855c authored by Jacques-Etienne Beaudet's avatar Jacques-Etienne Beaudet Committed by Stephane Nicoll

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
parent 5ef69036
...@@ -114,6 +114,8 @@ public class FlywayAutoConfiguration { ...@@ -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 @@ ...@@ -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 { ...@@ -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 { ...@@ -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);
......
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