if conditionals

if conditionals allow you to set specific blocks of code to run or not run depending on your flow file functionality needs.

Read more: Advanced Flow File

Note: The flow feature requires Liquibase 4.17+.

if conditionals code format

If conditionals exist within their own block of code within a Stage in a Flow file. A few formatting rules to note are:

  • The entire conditional must be encompassed by "quotes".
  • Variables must begin with $ and be encompassed by {curly braces}.

For example:


Any defined variable can be used as a conditional, including environment variables and global variables.

Read more: variables and include feature

Implement if conditionals

Values within if conditionals are called on in the format below. If the conditional value is set to true, it will run the command. If the conditional value is set to false, it will not run the command.

-type: liquibase
    command: checks run
    cmdArgs: {checks-scope: changelog}
-type: liquibase
    command: updatesql

When liquibase flow runs, messages will appear in the CLI after the flow file executes each section. Notice in the sample message below it says Executing 'liquibase' checks run because the environment variable above is set to true. You will also notice the message Skipping action: 'liquibase' updatesql because condition 'dev != dev' evaluated to false.' This is the best location to find why if conditionals did or did not run successfully. If you expected a conditional to run successfully and it did not, you are better equipped to adjust the flow file accordingly.

* Executing 'liquibase' checks run

Executing Quiality Checks against example-changelog.sql

Executing all changelog checks because a valid license key was found!

Warning: No database checks were run. Make sure the checks-scope property includes "database" to run database checks. In the CLI set --checks-scope+'changelog.database" or set an environment variable.
LIQUIBASE_COMMAND_CHECKS_SCOPE=database. Learn more at https://docs.liquibase.com/quality-checks

INFO: Checks executed against SQL generated by H2 at jdbc:h2:tcp://localhost:9090/mem:dev.
Changesets Validated: in example-changelog.sql
    ID: 1; Author: your.name
    ID: 2; Author: your.name
    ID: 3; Author: other.dev
Checks run against each changeset:
    Changesets Must Have a Context Assigned (Short names: ChangesetCommentCheck)
    Changesets Must Have a Context Assigned (Short names: ChangesetContextCheck)
    Changesets Must Have a Label Assigned (Short names: ChangesetLabelCheck)
    Check Table Column Count (Short names: TableColumnLimit)
    Rollback Required for Changeset (Short names: RollbackRequired)
    Warn on Detection of 'GRANT' statements (short names: SQLGrantWarn)
    Warn on Detection of 'REVOKE' statements (short names: SQLRevokeWarn)
    Warn on Detection of grant that contains 'WITH ADMIN OPTION' (Short names: SqlGrantAdminWarn)
    Warn on Detection of grant that contains 'WITH GRANT OPTION' (Short names: SqlGrantOptionWarn)
    Warn when 'DROP COLUMN' detected (Short names: ChangeDropColumnWarn)
    Warn when 'DROP TABLE' detected (Short names: ChangeDropTableWarn)
    Warn when 'MODIFY <column>' detected (Short names: ModifyDataTypeWarn)
    Warn when 'TRUNCATE TABLE' detected (Short names: ChangeTruncateTableWarn)
Changelogs Checks Skipped Due to unsupported changeset type for this check:
    Require primary key when creating table (Short names: PrimaryKeyOnCreateTable) skipped for:
Liquibase command 'checks run' was executed successfully.

* Skipping action: 'liquibase updatesql because condition 'dev != dev' evaluated to false.