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.

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.

SQL example

--changeset your.name:changeset1 runOnChange:true
CREATE or REPLACE . . .

XML example

<changeSet  author="your.name"  id="changeset01"  runOnChange="true" >
        <createProcedure>
        . . .
        </createProcedure>
</changeSet>

YAML example

changeset:
      id: changeset1
      author: your.name
      runOnChange: true
      changes:
      . . .

JSON example

{ "changeSet" :
        {"id": changeset1,
        "author": your.name,
        "runOnChange": true,
        "changes":
          [
           . . .
          ]
        }
 }

Related links