liquibase-maven-plugin 和 hibernate:diff 命令不产生任何变更集
liquibase-maven-plugin and hibernate: diff command does not produce any changeset
我正在尝试将 liquibase 和 hibernate 放在一起,以便在开发或更新实体时生成新的变更集。我已经在非 jpa 场景中享受了 liquibase,所以我决定在这个用例中使用它。我想我正确地设置了一切(检查 here 子模块 jsfcihelloworld)但是当我 运行 mvn liquibase:diff -Dliquibase.diffChangeLogFile=/tmp/database.change.log.txt
没有发现任何变化时,这里是(相关部分)输出:
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
看起来 liquibase 找到了变化,generic_good
move_something
和 move_somenthing_complex
是新的实体,但是 changelog 是空的。我错过了什么?
输出对我来说似乎有点误导,因为你是对的,看起来 liquibase 发现 generic_good move_something 和 move_somenthing_complex.
的变化
我认为问题出在您使用的是 liquibase diff, but I think you want to use liquibase diffChangeLog。 diffChangeLog 实际上生成一个 运行
我看到的另一个问题是您正在使用
-Dliquibase.diffChangeLogFile=
在文档中,输出文件为:
- 差异是--outputFile=mydiff.txt和
- diffChangeLog 是 --changeLogFile=dbchangelog.xml
我正在尝试将 liquibase 和 hibernate 放在一起,以便在开发或更新实体时生成新的变更集。我已经在非 jpa 场景中享受了 liquibase,所以我决定在这个用例中使用它。我想我正确地设置了一切(检查 here 子模块 jsfcihelloworld)但是当我 运行 mvn liquibase:diff -Dliquibase.diffChangeLogFile=/tmp/database.change.log.txt
没有发现任何变化时,这里是(相关部分)输出:
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
看起来 liquibase 找到了变化,generic_good
move_something
和 move_somenthing_complex
是新的实体,但是 changelog 是空的。我错过了什么?
输出对我来说似乎有点误导,因为你是对的,看起来 liquibase 发现 generic_good move_something 和 move_somenthing_complex.
的变化我认为问题出在您使用的是 liquibase diff, but I think you want to use liquibase diffChangeLog。 diffChangeLog 实际上生成一个 运行
我看到的另一个问题是您正在使用
-Dliquibase.diffChangeLogFile=
在文档中,输出文件为:
- 差异是--outputFile=mydiff.txt和
- diffChangeLog 是 --changeLogFile=dbchangelog.xml