我在 Springboot 应用程序中使用 Liquibase (3.5.1)
。我正在使用基于 SQL 的更改日志文件。添加新的更改集最终会显示上一个更改集的校验和验证错误。
初始更新日志文件 -
--liquibase formatted sql
--changeset tanmoy:1
create table serviceInstances (
serviceId varchar(60),
orgId varchar(60),
spaceId varchar(60),
primary key (serviceId,orgId)
);
添加如下新变更集时 -
--changeset tanmoy:2
create table serviceBindings (
bindingId varchar(30) primary key,
serviceId varchar(30),
appId varchar(30),
timeStamp BIGINT
);
迁移失败,出现此错误日志 -
Caused by: liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
classpath:/db/changelog/db.changelog-master.sql::1::tanmoy was: 7:d15516f48de6531d1727cca8c56ec95a but is now: 7:3c7718f34f78701e0d2cadbf8278c1fa
at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:266) ~[liquibase-core-3.5.1.jar:na]
at liquibase.Liquibase.update(Liquibase.java:210) ~[liquibase-core-3.5.1.jar:na]
at liquibase.Liquibase.update(Liquibase.java:192) ~[liquibase-core-3.5.1.jar:na]
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434) ~[liquibase-core-3.5.1.jar:na]
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391) ~[liquibase-core-3.5.1.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 16 common frames omitted
不明白为什么更改了上一个更改集的校验和,但未进行验证。是因为我在更改日志文件中添加了新的更改集吗?如果是,那么我如何添加新的更改集?
在流程级别上,所有流程都是incrementally
完成的。例如,当我们创建一个表并想要对表进行更改时,我们会为您提供一个新的增量数字。有了这个数字,我们确定了在我们创建的那个中changes
。这就像你在问题中添加了一些新的东西。因此,您需要增加liquibase.xml
文件中的id
。如果对当前图表进行了更改,请执行以下操作。
<changeSet id="73" author="fcelik">
<comment>This change adds to customer_order table.</comment>
<addColumn tableName="customer_order">
<column name="owner_id" type="BIGINT">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
您的文件必须是liquabase.xml
的不匹配值。要在创建文件之间执行的操作(通常跟踪增量路径)。例如,我在此处的customer_order
表中添加了一个新列。请注意,当您使用标签时,<addColumn>
。