In my spring-boot project I'm using out-of-the-box integration for Flyway (org.flywaydb.flyway-core
) and have some migration scripts which are executed on startup and managed via default flyway_schema_history
-table.
The project also uses a module bringing its own flyway migration scripts, which are migrated programmatically and keeping track of migrations in an other moduleX_schema_history
-table.
As the migrations of the main-project needs to work on some of the tables created via the modules migration, the module-migration needs to happen before the flyway-plugin migrates the main-projects scripts.
How can I achieve executing modules migration programmatically and before the main-apllications fly-integration kicks in? How and when is the flyway-plugin migration triggered?
//EDIT:
I tried to execute code before FlywayAutoConfiguration via a @Configuration
class annotated with
@AutoConfigureBefore({FlywayAutoConfiguration.class})
@AutoConfigureAfter({DataSourceAutoConfiguration.class})
but unfortunatly the class is still instanciated after FlywayAutoConfiguration
.
//EDIT: I asked the related (more general) question how to order AutoConfiguration from modules, too How to use @AutoConfigureOrder in a spring boot configuration class from a module - Stack Overflow