onValidationFail

onValidationFail is an attribute you can specify in changesets in your changelog. It controls what Liquibase does when a changeset fails validation. Values are HALT and MARK_RAN. Default: HALT.

onValidationFail does not relate to checksum validation. This attribute is only valid for XML, JSON, and YAML changesets because Liquibase does not validate the SQL within SQL changesets before it is executed.

Uses

Liquibase performs basic validation on changesets you deploy, such as checking whether a change is valid for your database or whether you have specified all required attributes. If a changeset fails this validation, by default Liquibase halts the deployment and return an error message. For example:

Unexpected error running Liquibase: Error parsing line 40 column 65 of example-changelog.xml: cvc-complex-type.4: Attribute 'id' must appear on element 'changeSet'.

However, you can set onValidationFail to MARK_RAN if you want Liquibase to mark a failing changeset as run and continue with the deployment.

Tip: If your changesets are failing validation and you want a deployment to proceed, it is a best practice to fix the underlying cause of the failures instead of skipping them with onValidationFail.

Syntax

Note: All changelog attributes use the camelCase format.

databaseChangeLog:
  -  changeSet:  
      id:  1
      author:  adrian
      onValidationFail:  MARK_RAN
      changes:
        -  createTable:
            tableName:  company
            columns:
              -  column:
                  name:  address
{
  "databaseChangeLog": [
    {
      "changeSet": {
        "id": "1",
        "author": "adrian",
        "onValidationFail": "MARK_RAN",
        "changes": [
          {
            "createTable": {
              "tableName": "company",
              "columns": [
                {
                  "column": {
                    "name": "address"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xmlns:pro="http://www.liquibase.org/xml/ns/pro"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
        http://www.liquibase.org/xml/ns/pro
        http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">

    <changeSet  id="1"  author="adrian"  onValidationFail="MARK_RAN">
        <createTable  tableName="company">
            <column  name="address"  type="varchar(255)"/>
        </createTable>
    </changeSet>

</databaseChangeLog>

Related links