-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document that schema.sql and data.sql will still be run when using Flyway or Liquibase but discourage their use #20920
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
Comments
That's the wrong expectation I am afraid. When you run a database migration with Liquibase, this is taking control of the schema and the basic Said differently, you can't combine, Execute Liquibase Database Migrations on Startup The name of the latter section has been renamed in |
Okay. But then the bug is with H2. Since there both is executed. |
I don't know what you mean by "bug is with H2". This project looks wrong to me as you are using two different initialisation system. Either you use liquibase (or flyway) or either you use the schema/data pair. |
Example-project: https://github.com/hauer-io/liquibase |
They behave differently because one is creating the schema via Hibernate and one does not. According to the documentation, embedded databases are created automatically on startup if you're using JPA. That's a sensible default since the database and its content are destroyed at every run. I've added the following to the configuration on your app: spring:
jpa:
hibernate:
ddl-auto: none To make sure that the database is not created by Hibernate and now the two tests fail the same way as the behaviour is the same. This is what I was trying to say with using two competing schema management feature (i.e. schema.sql & data.sql vs. liquibase). The |
So in case of embedded database I have to explicit disable hibernate creation to avoid confusion? Thanks for your support. I was confused since I just change the database. |
According to the documentation for spring.jpa.hibernate.ddl-auto:
So there should be no need to set it none, right? I updated the example so that it is clear, that both are run in case of tests. |
@hauer-io there is no need to close the issue. I've triaged it already.
That's the other part of the problem I meant to investigate indeed. We're supposed to detect liquibase & flyway. I intended to figure out what's going on as part of looking at this issue in more details. Long story short, don't expect to be able to use |
@hauer-io, I had similar questions only 10 days after you, that's curious! After a bit of research, learning and testing, I agree with the current expected behaviour. In the end, I was able to achieve my goals properly setting up Liquibase (e.g. using "context" attributes) and the final solution is quite clean. However, a bit more clarity in both docs would have surely made everything more straightforward. 9.10.3. Initialize a DatabaseMaybe it would be worth clarifying the behaviour in the admonition blocks. I was thinking if it. would be better grouping everything in a single block.
9.10.5. Use a Higher-level Database Migration ToolMaybe it would be worth adding an admonition block reminding that the migration scripts will be run both for 5. Data propertiesMaybe it would be worth adding a brief description to the |
@nikmanzotti Thanks for the feedback. Can you turn that into a PR that updates the documentation? |
|
This seems to be resolved via #21077. |
Thanks @izeye, not 100%. I'd like to investigate what's going on with #20920 (comment) |
Looking at the sample in its current form, Liquibase is being detected and, as a result, Hibernate is not attempting to create the schema. However, this leads to a failure as
The code doesn't match the documentation updates made in #21077. |
|
Expected Behavior:
Actual Behavior:
Failed approaches:
Initial analyse:
Example-project: https://github.com/hauer-io/liquibase
The text was updated successfully, but these errors were encountered: