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

Comment From: wilkinsona

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.