Search code examples
liquibaseliquibase-sql

On Fail Message for SQL Formatted ChangeSets


I can add preconditions to formatted SQL scripts, like the docs say:

--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM my_table

but I can't seem to add an onFailMessage or onErrorMessage to them.

Is there a way I've missed?

Or should I just code up something like
--precondition-onFailMessage:Better luck next time
and send a PR?


Solution

  • If I get it right, onFailMessage and onErrorMessage attributes are not supported for SQL formatted changeSets.

    I believe FormattedSqlChangeLogParser.java parses SQL formatted changeSets.

    And I just can't find parsers for onFailMessage or onErrorMessage in this class, so I believe these attributes are just getting ignored.

    The correct code should be (if it was getting parsed):

    --preconditions onFail:HALT onError:HALT onFailMessage:your_message

    So --precondition-onFailMessage:Better luck next time won't do anything to your changeSets, so I suppose there's no need to include it in your PR.