2
votes

I have a changeset

<changeSet id="ABC123" author="davnicwil">
  <preConditions onFail="HALT">
    <sqlCheck expectedResult="3">SELECT count(*) FROM little_pigs</sqlCheck>
  </preConditions>
  <sql>DROP TABLE wolf</sql>
</changeSet>

When there are only 2 rows in little_pigs, it fails with this error message

liquibase.exception.MigrationFailedException: 
  Migration failed for change set migrations.xml::ABC123::davnicwil:
    Reason: 
      migrations.xml : SQL Precondition failed.  Expected '3' got '2'

I'd like a more meaningful error message, such as

liquibase.exception.MigrationFailedException: 
  Migration failed for change set migrations.xml::ABC123::davnicwil:
    Reason: 
      3 little pigs are required to defeat the wolf

Is there any way to configure a custom error message like this, for the preconditions?

A static message is fine. If a dynamic message is possible, all the better.

1

1 Answers

4
votes

I think that

onFailMessage   Custom message to output when preconditions fail. Since 2.0

(http://www.liquibase.org/documentation/preconditions.html) is what you need for static message. I didn't get what do you expect to have for "dynamic message" but you can mplement your own logic using <customPrecondition>