Reputation: 30342
I'm on Liquibase Version: 2.0.1.
Is it possible to have pre-conditions in a formatted sql file? If so how? An example would be appreciated.
I would like to do somthing like this but in sql formatted file.
<preConditions onFail="WARN">
<sqlCheck expectedResult="0">select count(*) from oldtable</sqlCheck>
</preConditions>
Upvotes: 8
Views: 11261
Reputation: 15773
Outdated: The feature has been added in latest Liquibase version. See https://stackoverflow.com/a/27494608/256561 for up to date solution.
Unfortunately, the current FormattedSql
parser does not support preconditions.
You could extend the default class with your own parser that would support it if you need, however. See http://liquibase.org/extensions
Upvotes: 2
Reputation:
Specifying preconditions in a liquibase formatted sql file is now supported. Within a changeset definition, the preconditions may be specified using the following format (copied from the official docs):
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM my_table
It is noted in the documentation that only the sql check precondition type is supported at this time.
Complete documentation is available at the liquibase website.
Upvotes: 12