liquibaseliquibase-hibernate

liquibase-maven-plugin and hibernate: diff command does not produce any changeset


I am trying to put together liquibase and hibernate to generate new changesets as entities are developed or updated. I already enjoyed liquibase in a non-jpa scenario so I decide to use it in this usecase. I think I set up everything properly (check here the submodule jsfcihelloworld) but when I run mvn liquibase:diff -Dliquibase.diffChangeLogFile=/tmp/database.change.log.txt no change is found, here is the (relevant part of the) output:

Starting Liquibase at 15:40:51 (version 4.2.2 #36 built at 2020-12-09 20:07+0000)
[INFO] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringBeanDatabase could not be instantiated
[INFO] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringPackageDatabase could not be instantiated
[INFO] Executing on Database: jdbc:postgresql://localhost:5432/postgres
[WARNING] Namespace of the [javax.xml.bind.annotation.XmlSchema] annotation does not match [http://www.hibernate.org/xsd/orm/hbm]. Processing bindings will probably fail.
[INFO] Reading hibernate configuration hibernate:ejb3:jscihw?dialect=org.hibernate.dialect.PostgreSQL95Dialect
....
[INFO] Performing Diff on database postgres @ jdbc:postgresql://localhost:5432/postgres (Default Schema: public)
[INFO] Found table kind
[INFO] Found table kind
[INFO] Found table users
[INFO] Found table users
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table generic_good
[INFO] Found table generic_good
[INFO] Found table move_something_complex
[INFO] Found table move_something_complex
[INFO] Found table generic_good
[INFO] Found primary key generic_goodPK
[INFO] Found column id uuid
[INFO] Found column description varchar(255)
[INFO] Found table kind
[INFO] Found primary key kindPK
[INFO] Found column id uuid
[INFO] Found column name varchar(255)
[INFO] Found table users
[INFO] Found primary key usersPK
[INFO] Found column id uuid
[INFO] Found column age int4
[INFO] Found column name varchar(255)
[INFO] Found column since timestamp
[INFO] Found column surname varchar(255)
[INFO] Found table move_something_complex
[INFO] Found unique constraint UK_b1eoi866ojglucgyhvmfssp83 on move_something_complex(component_task)
[INFO] Found column main_task uuid
[INFO] Found column component_task uuid
[INFO] Found column id uuid
[INFO] Found table move_something
[WARNING] Hibernate primary key name is probably truncated. move_somethinPK
[WARNING] Changing hibernate primary key name to move_somethingPK
[INFO] Found primary key move_somethingPK
[INFO] Found column DTYPE varchar(31)
[INFO] Found column id uuid
[INFO] Found column ends_at timestamp
[INFO] Found column starts_at timestamp
BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed.
[INFO] /tmp/database.change.log.txt exists, appending
[INFO] No changes found, nothing to do
[INFO] Differences written to Change Log File, /tmp/database.change.log.txt

It looks like liquibase find changes, generic_good move_something and move_somenthing_complex are the new entities, but changelog is empty. What am I missing?


Solution

  • The output seemed a little misleading to me, because you are right, it looks like liquibase found changes for generic_good move_something and move_somenthing_complex.

    I believe the issue is you were using liquibase diff, but I think you want to use liquibase diffChangeLog. diffChangeLog actually generates a run

    Another issue I see is you are using

    -Dliquibase.diffChangeLogFile=

    In the documentation, the output files for: