Reputation: 558
I have a precondition to check more than one record in DML file using Liquibase changeSet and YAML format:
My requirement to add precondition which check record should exist:
- changeSet:
id: 18.5.1
author: saggarwal
comment: PROD-5303 | DELETE | TEMPLATE_COLUMN_MAPPPING | ATT
preConditions:
- onFail: MARK_RAN
- sqlCheck:
-not:
expectedResult: 0
sql: select count(*) from es_email;
changes:
- delete:
tableName: es_email
where: template_id =select id from abc where name= 'XYZ';
But it is not working. How can we check this? Please give some example.
In XML we do like:
<preConditions onFail="MARK_RAN">
<not>
<sqlCheck expectedResult="0">
select count(*) from es_email;
</sqlCheck>
</not>
</preConditions>
...but in YAML?
Upvotes: 2
Views: 4520
Reputation: 106027
The first problem with your YAML is that there's no space after the -
in -not:
, so it doesn't parse. There are other problems, however, the most apparent of which is that in your XML, sqlCheck
is a child of not
, but in your YAML they are siblings.
The documentation for YAML in Liquibase is hilariously bad. However, googling "Liquibase YAML sqlCheck" leads us to the tests, a quick survey of which suggest the following refinement to your YAML:
preConditions:
- onFail: MARK_RAN
- not:
- sqlCheck:
expectedResult: 0
sql: select count(*) from es_email;
Upvotes: 2