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.

Tip: All changeset attributes use the camelCase format.

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 diff-ing 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.

Using runOnChange

The default value for runOnChange is false. Set runOnChange to true for changesets that should be executed whenever they are modified.

XML example

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

SQL example

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

YAML example

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

JSON example

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