Generate Database Migration from hibernate model #43723
Description
Description
Today, there is no real way to generate db migrations.
Current Process: When creating a database migration, the workflow is quite cumbersome:
- Modify the entity.
- Check the update script in the dev UI (when accessible—sometimes the app doesn't even start, making it unavailable).
- Manually create a new migration file.
- Customize the update script as needed.
New Workflow: the process is simplified to:
- Modify the entity.
- Customize the update script as needed.
This could then be executed either from the dev UI, or by registering a new maven / gradle task, that way it is accessible even if the app does not start.
I remember when I first started coding in PHP, doctrine was doing this very well: https://symfony.com/bundles/DoctrineMigrationsBundle/current/index.html
Implementation ideas
Liquidbase provide a diff command that compute the difference between two database, and a generate changelog command that generate migrations from this diff.
Instead of comparing real databases, we could compare a virtual database created from hibernate persistence model and the local dev db.
There is already some work around a hibernate virtual db, but it is not working with quarkus:
https://github.com/liquibase/liquibase-hibernate
See linked PR
Activity