2

Liquibase xml based changeset block:

<preConditions>
  <not>
    <tableExists tableName="alarm" schemaName="public"/>
  </not>
</preConditions>

How it should be in "liquibase formatted sql"? Official documentation of Liquibase give only xml based

ykembayev
  • 108
  • 1
  • 8

1 Answers1

7

Use this:

--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:0 SELECT count(*) FROM information_schema.tables where table_name = 'alarm';

The expectedResult is a String in liquibase and the evaluation will do a String comparsion. So whatever your sql returns needs to match exactly (including case sensitivity).

You can also check the unit test class FormattedSqlChangeLogParserTest for further examples.

Jens
  • 6,243
  • 1
  • 49
  • 79