ChangesetContextCheck

This check enforces the Liquibase best-practice recommendation to assign a context to every changeset to provide better deployment control and to enhance traceability and granularity of deployments across changesets.

Note: Context and Label are similar, but the best-practice is to use context for “deployment environments” and labels more like free-form tags for features, content, release, or other process-centric filter.

Uses

Use the check to enhance deployment control of specific changesets by requiring one or more contexts be assigned to every changeset in a changelog. Whether in automation or manual testing of proposed schema changes at the dev level, contexts provide better deployment control. Using contexts allows just the changesets which match specified contexts filter(s) to be run. For example, a team could provide contexts to change sets by “dev”, “staging”, “prod”, or all three “dev, staging, prod” and when a Liquibase job is run, only the specified subset of context-matching changesets will be deployed. This quality check, like other checks, can be configured with a “severity” level which returns an exit code designed to stop automated jobs, giving your team time to apply this Liquibase best practice.

Run the ChangesetContextCheck check

The ChangesetContextCheck check is enabled by default, so you will not need to turn it on if you have not changed your settings previously. To run the ChangesetContextCheck check, ensure you have a Liquibase Pro license and the checks-scope property includes changelog. The checks-scope parameter is set in the default properties file, environment variable, or any standard method. Then, check the changelog to see if ChangesetContextCheck is enabled.

Enable the ChangesetContextCheck check by running the following command in the CLI:

liquibase checks enable --check-name=ChangesetContextCheck
Short Name Scope Enabled Severity Customization Description
ChangesetContextCheck changelog

true

Default value: 0

  • 'INFO' | 0
  • 'MINOR' | 1
  • 'MAJOR' | 2
  • 'CRITICAL' | 3
  • 'BLOCKER' | 4

<None>

This check enforces the Liquibase recommendation that contexts be assigned to each changeset to provide better deployment control and to enhance traceability of efforts across changesets.