runOnChange

The runOnChange changeset attribute runs the change the first time it is detected and each time the changeset is modified.

Liquibase determines that a changeset has been modified by comparing the MD5 checksum for the changeset to the checksum stored in the DATABASECHANGELOG table. If the runOnChange attribute is not set or set to false, Liquibase will generate a checksum error if a changeset is modified after it has been deployed to a database. This is done to notify you that a changeset has been unexpectedly modified.

Note: runOnChange does not run if you only make changes to whitespace and comments.

Uses

The runOnChange attribute is useful for changesets that you want to run each time they are modified. Common examples are views and stored procedures that use the CREATE OR REPLACE logic. If you copy the entire text of the stored procedure to a new changeset each time you make a change, you not only end up with a lengthy changelog, but you lose the merging and differentiating power of your source control. Instead, place the text of the stored procedure in a changeset with a runOnChange="true" attribute. The stored procedure is recreated only when there is a change to the text.

Syntax

Note: All changelog attributes use the camelCase format.

The default value for runOnChange is false. Set runOnChange to true on changesets you want to execute whenever they are modified.

--changeset your.name:changeset01 runOnChange:true
CREATE or REPLACE . . .
{
  "changeSet" :
    {
      "id": "changeset01,"
      "author": "your.name",
      "runOnChange": true,
      "changes": [
        {
          . . .
        }
      ]
    }
  }
}
- changeset:
    id: changeset01
    author: your.name
    runOnChange: true
    changes:
      - . . .
<changeSet  author="your.name"  id="changeset01"  runOnChange="true" >
        <createProcedure>
        . . .
        </createProcedure>
</changeSet>

Related links