Search code examples
liquibase

Why is Liquibase throwing this error: Could not parse a SqlCheck precondition


I'm trying to add preconditions to a SQL formatted changeset in Liquibase 3.1.1

--preconditions onFail=HALT onError=HALT
--precondition-sql-check expectedResult=0 SELECT COUNT(*) FROM USER_ERRORS WHERE TYPE = 'PROCEDURE'
--changeset myteam:101 runAlways:true

Liquibase raises this error when I run a status:

Liquibase status Failed: Could not parse a SqlCheck precondition from 'expectedResult=0 SELECT COUNT(*) FROM USER_ERRORS WHERE TYPE = '
PROCEDURE''.

What's wrong with that precondition syntax?


Solution

  • There needs to be a colon instead of an equals char after "expectedResult".

    So the line should be:

    --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM USER_ERRORS WHERE TYPE = 'PROCEDURE'
    

    Then it should work.

    EDIT: (Documentation was updated. See Nathans comment.)

    This is also wrong on the liquibase documentation for the Formatted SQL Changelogs.