-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Database migrations may not have run before JdbcTemplate is used #13155
Comments
Furthermore, even if I change the |
I don't know but it definitely runs as part of the As for your initial request, I think what we have right now is consistent with many other features. If you use Can you please share a sample that demonstrates that Flyway is not called when that event is fired? |
Please ignore my comment regarding Regarding |
That's not what I wrote. Please look at the link and the explanation again.
You don't have a dependency on Flyway, you have a dependency on a |
This feels like a bug to me. If you consume the auto-configured |
I have also been confused about this. If this is consistent with other features, please provide at least the corresponding instructions in the spring boot documentation. |
@nameof Please read my comment that is immeadiately before yours. It’s a bug that we intend to fix. |
@wilkinsona got it , really sorry for this |
We have the same problem with 2.2.4.RELEASE. Wasn't this supposed to be fixed? |
@jordanms This issue should have been fixed for quite some time. If you're facing a similar problem, please open a new issue and provide a small sample application that demonstrates it. |
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.
demo-4.zip
The text was updated successfully, but these errors were encountered: