Skip to content

Commit

Permalink
Make sure the default datasource FlywayContainer is returned first
Browse files Browse the repository at this point in the history
Ideally we wouldn't rely on this but given we had a test relying on it,
better keep this behavior given it doesn't cost much.

(cherry picked from commit ec04931)
  • Loading branch information
gsmet committed Aug 11, 2023
1 parent 19577a6 commit 8324fc5
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ void createBeans(FlywayRecorder recorder,
if (DataSourceUtil.isDefault(dataSourceName)) {
flywayContainerConfigurator.addQualifier(Default.class);

// Flyway containers used to be ordered with the default database coming first.
// Some multitenant tests are relying on this order.
flywayContainerConfigurator.priority(10);

flywayContainerQualifier = AnnotationInstance.builder(Default.class).build();
} else {
String beanName = FLYWAY_CONTAINER_BEAN_NAME_PREFIX + dataSourceName;
Expand All @@ -208,6 +212,7 @@ void createBeans(FlywayRecorder recorder,
flywayContainerConfigurator.addQualifier().annotation(DotNames.NAMED).addValue("value", beanName).done();
flywayContainerConfigurator.addQualifier().annotation(FlywayDataSource.class).addValue("value", dataSourceName)
.done();
flywayContainerConfigurator.priority(5);

flywayContainerQualifier = AnnotationInstance.builder(FlywayDataSource.class).add("value", dataSourceName)
.build();
Expand All @@ -225,9 +230,11 @@ void createBeans(FlywayRecorder recorder,

if (DataSourceUtil.isDefault(dataSourceName)) {
flywayConfigurator.addQualifier(Default.class);
flywayConfigurator.priority(10);
} else {
String beanName = FLYWAY_BEAN_NAME_PREFIX + dataSourceName;
flywayConfigurator.name(beanName);
flywayConfigurator.priority(5);

flywayConfigurator.addQualifier().annotation(DotNames.NAMED).addValue("value", beanName).done();
flywayConfigurator.addQualifier().annotation(FlywayDataSource.class).addValue("value", dataSourceName).done();
Expand Down

0 comments on commit 8324fc5

Please sign in to comment.