Description
Using Spring Boot 2.0.2.RELEASE I set up a simple project that uses Flyway for migrations and JDBC template for accessing the DB. I expect all Flyway migrations to finish running before I can use the datasource. However, I noticed that PostConstruct runs before Flyway migrations. That means I access the old version of the schema, causing application failures.
As mentioned here, one may annotate the component that uses JdbcTemplate with: @DependsOn({"flyway", "flywayInitializer"})
, but this is cumbersome and error prone - it is easy to forget to do so, and I don't see a reason this shouldn't be the default behaviour.
The attached project is a minimal Spring Boot application with a single component that uses the database in its PostConstruct method. The output shows that PostConstruct is called before Flyway runs.