commit
1a9065f46f
|
@ -125,7 +125,7 @@ public class FlywayAutoConfiguration {
|
|||
ObjectProvider<JavaMigration> javaMigrations, ObjectProvider<Callback> callbacks) {
|
||||
FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader());
|
||||
DataSource dataSourceToMigrate = configureDataSource(configuration, properties, dataSourceProperties,
|
||||
flywayDataSource.getIfAvailable(), dataSource.getIfAvailable());
|
||||
flywayDataSource.getIfAvailable(), dataSource.getIfUnique());
|
||||
checkLocationExists(dataSourceToMigrate, properties, resourceLoader);
|
||||
configureProperties(configuration, properties);
|
||||
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
|
||||
|
|
|
@ -77,6 +77,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Stephane Nicoll
|
||||
* @author Dominic Gunn
|
||||
* @author András Deák
|
||||
* @author Takaaki Shimbo
|
||||
*/
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class FlywayAutoConfigurationTests {
|
||||
|
@ -162,6 +163,15 @@ class FlywayAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void flywayMultipleDataSources() {
|
||||
this.contextRunner.withUserConfiguration(FlywayMultipleDataSourcesConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(Flyway.class);
|
||||
assertThat(context.getBean(Flyway.class).getConfiguration().getDataSource())
|
||||
.isEqualTo(context.getBean("flywayDataSource"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void schemaManagementProviderDetectsDataSource() {
|
||||
this.contextRunner
|
||||
|
@ -509,6 +519,27 @@ class FlywayAutoConfigurationTests {
|
|||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class FlywayMultipleDataSourcesConfiguration {
|
||||
|
||||
@Bean
|
||||
DataSource firstDataSource() {
|
||||
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:first").username("sa").build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
DataSource secondDataSource() {
|
||||
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:second").username("sa").build();
|
||||
}
|
||||
|
||||
@FlywayDataSource
|
||||
@Bean
|
||||
DataSource flywayDataSource() {
|
||||
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:flywaytest").username("sa").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class FlywayJavaMigrationsConfiguration {
|
||||
|
||||
|
|
Loading…
Reference in New Issue