在 Liquibase 中,
update
和 delete
更改类型使用 where
查询来定位多行。
有没有办法强制这两种更改类型影响的行数?
类似以下内容:
update:
tableName: MY_TABLE
columns:
- column: {name: col1, value: col1_value}
where: col2 = 'col2_value'
expectedResult: 2
preConditions
不是一个合适的解决方案,因为:
changes
可以包含许多 update
/delete
查询您可以为此使用 sqlCheck 前提条件。
只需复制更新/删除变更集的条件并检查预期的行数。
我对 yaml 表示法不太熟悉,但它看起来像这样:
changeSet:
id: foo
author: bar
preConditions:
- onFail: MARK_RAN
- sqlCheck:
expectedResult: 2
sql: SELECT COUNT(*) FROM MY_TABLE WHERE col2 = 'col2_value'
changes:
- update:
tableName: MY_TABLE
columns:
- column: {name: col1, value: col1_value}
where: col2 = 'col2_value'