Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple flyway instances #38576

Closed
wants to merge 1 commit into from
Closed

Add support for multiple flyway instances #38576

wants to merge 1 commit into from

Conversation

bekoenig
Copy link

@bekoenig bekoenig commented Nov 27, 2023

Hi,

after my comment in another discussion to provide support for auto-configuring multiple beans I would like to contribute my solution for flyway. This is an integrated version from an internal adaption which we use in my company. The implementation is fully compatible with the current default behaviour.

To use the new behaviour you have to define properties like spring.flyway.instances.{name}.*. The {name} is a custom definition for the flyway instance. Every property tree overrides than the global properties which are placed in spring.flyway.*. In general these are default-schema and location, but all other work too. Every instance can be disabled separately. Auto completion for properties works in the IDE too.

In order to bind configuration beans to a flyway instance a new annotation @FlywayInstance({name}) exists, which binds a bean to the specific instance by the {name} defined in the properties. When no explicit binding exists, the bean will be the default for all instances. For FlywayConnectionDetails, FlywayDataSource and FlywayMigrationStrategy a specific bean will be preferred. For FlywayConfigurationCustomizer und Callback the default and the instance specific beans are joined by order. Only JavaMigration expects an explicit binding, to avoid configuration errors. A predefined FlywayMigrationInitializer will only be used in the default mode. In multi instance mode every flyway bean gets its own FlywayMigrationInitializer.

Most tests work and I added tests for the new feature. I can add documentation based on feedback.

Greetings,
Ben

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Nov 29, 2023

Thanks, @bekoenig. It's interesting to see how you've tackled the problem for Flyway specifically. Unfortunately, as I said on #15732, we cannot merge this. We don't want to add something that's Flyway-specific that hampers our ability to provide a broader solution in the future.

@wilkinsona wilkinsona closed this Nov 29, 2023
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants