Call FlywayConfigurationCustomizers after applying all other config
Closes gh-32070
This commit is contained in:
parent
d546ea515a
commit
5470a6b349
|
|
@ -119,10 +119,9 @@ public class FlywayAutoConfiguration {
|
|||
configureProperties(configuration, properties);
|
||||
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
|
||||
configureCallbacks(configuration, orderedCallbacks);
|
||||
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
|
||||
configureFlywayCallbacks(configuration, orderedCallbacks);
|
||||
List<JavaMigration> migrations = javaMigrations.stream().collect(Collectors.toList());
|
||||
configureJavaMigrations(configuration, migrations);
|
||||
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
|
||||
return configuration.load();
|
||||
}
|
||||
|
||||
|
|
@ -245,12 +244,6 @@ public class FlywayAutoConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
private void configureFlywayCallbacks(FluentConfiguration flyway, List<Callback> callbacks) {
|
||||
if (!callbacks.isEmpty()) {
|
||||
flyway.callbacks(callbacks.toArray(new Callback[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void configureJavaMigrations(FluentConfiguration flyway, List<JavaMigration> migrations) {
|
||||
if (!migrations.isEmpty()) {
|
||||
flyway.javaMigrations(migrations.toArray(new JavaMigration[0]));
|
||||
|
|
|
|||
|
|
@ -467,6 +467,17 @@ class FlywayAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void callbackAndMigrationBeansAreAppliedToConfigurationBeforeCustomizersAreCalled() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, FlywayJavaMigrationsConfiguration.class,
|
||||
CallbackConfiguration.class)
|
||||
.withBean(FlywayConfigurationCustomizer.class, () -> (configuration) -> {
|
||||
assertThat(configuration.getCallbacks()).isNotEmpty();
|
||||
assertThat(configuration.getJavaMigrations()).isNotEmpty();
|
||||
}).run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void batchIsCorrectlyMapped() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue