1

I would like to run a SQL precondition checking for each changeSet in my SQL changeLogFile. It is actually a precondition on the changeLog itself

Here is an extract of it :

--liquibase formatted sql

--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:"1.0" SELECT VERSION FROM VERSION_TABLE;

--changeset bob:1 failOnError:true dbms:oracle
ALTER INDEX XXX RENAME TO YYY;
--rollback YYY RENAME TO XXX;

Even if the precondition is actually not respected, liquibase still run all the changeset.

Does somebody knows if it is an error from my side or if liquibase does not allow preconditions on entire changeLog for SQL changeLog file ?

Thanks in advance !

Cedric C
  • 11
  • 2
  • The [documentation](https://www.liquibase.org/documentation/sql_format.html) says preconditions are only available per changeset. So I guess it is not possible. – Jens Jan 16 '20 at 18:34
  • Hi, Ok thanks for your answer, I relied on what I read here: https://www.liquibase.org/documentation/preconditions.html Thanks – Cedric C Jan 17 '20 at 07:56

2 Answers2

0

If you go through the documentation, then its stated that we can only apply pre-conditions on a specific change set. Also, only the SQL Check precondition is supported.

Liquibase doc for sql changelog files - https://www.liquibase.org/documentation/sql_format.html

0

One thing you could do is have a top-level master changelog in XML/YAML/JSON format and then use <include> or <includeAll> elements to include your liquibase formatted sql changelogs. If you do that, then you can have changelog-level preconditions.

SteveDonie
  • 8,700
  • 3
  • 43
  • 43