This is a simple project as demonstration how to generate liquibase change-logs with liquibase maven plugin from diff between database and JPA(Hibernate) entities without writing changelocks manually.
The project consists of two components.
- The App itself
- A Tool project that helps us to generate the changelock with the correct spelling for tables and columns
First step is installing the jar in local maven repo. Call
mvn clean install
in <project root>
This step is important because the liquibase plugin has a dependency to the Tools project artefact.
Second step is installing ans starting Postgres DB. Use the shell or pgAdmin Tool to create a new
database with the name
liquibase-test
Now you can change the JPA model a little bit in
de.zebrajaeger.liquibaseconfigtest.persistence.model
To create a diff go to
<project root>/app
and call
mvn clean compile liquibase:diff
This compiles the classes inclusive the model classes (important!) and creates the diff.
The result occurs in <project-root>/app/src/main/resources/liquibase-diff-changeLog.xml
After copying the changes to liquibase-changeLog.xml (and deletion of liquibase-diff-changeLog.xml)
the start of the application class
de.zebrajaeger.liquibaseconfigtest.LiquibaseConfigTestApplication
should be fine