hibernatequarkusliquibasequarkus-panacheliquibase-maven-plugin

Generate Liquibase diff changelog using Liquibase maven plugin in Quarkus


I am trying to use the Liquibase Maven plugin in Quarkus to generate a diff changelog based on my entities in my entity package. I noticed that it requires a referenceUrl in the liquibase.properties file as a reference for comparison.

In Spring framework, it is possible to achieve this by setting the reference URL to something like hibernate:spring:path-to-package?dialect=org.hibernate.dialect.PostgreSQLDialect. However, I could not find a workaround for it in Quarkus.

Is it even possible to achieve this in Quarkus, or should I write the changelog file manually?


Solution

  • Yes it can be done, you should set up the following properties in the liquibase.properties file:

    referenceUrl=hibernate:spring:<com.example.your.enitity.package>?dialect=org.hibernate.dialect.<YourDialect>
    referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
    diffChangeLogFile=src/main/resources/db/liquibase-diff-output.xml
    

    And then, after running a build with e.g. mvn clean install (to make sure that the entities' class files do exist) you can run something like mvn liquibase:diff to generate the DB diff comparing the entities to the database.