Customize a Policy check

Last updated: September 2, 2025

Some default Policy Checks have customization options that allow you to adjust the parameters used to determine whether a changeset meets the criteria of the check. You can adjust these parameters using the checks copy or checks customize command.

Procedure

In this example we will create a check that finds table truncation statements in a sample changelog by generating a copy of the SqlUserDefinedPatternCheck check.

1

Run this command in the CLI to create a copy of the check.

In the CLI, run this command:

liquibase checks copy --check-name=SqlUserDefinedPatternCheck
2

Initiate the customization process

A short name is a descriptive name that indicates what you want the check to search for in the database or changelog. In this example, we will provideSqlTruncateCheckas the short name, because we will be searching for any instances ofTruncate. The CLI will indicate that the new check was created fromSqlUserDefinedPatterncheck successfully:

New check 'SqlTruncateCheck' created from 'SqlUserDefinedPatternCheck'

3

Provide a search string for the policy check to search for.

In this example, we will useTRUNCATEbecause this check will search the database or changelog for theTRUNCATElabel. Set 'SEARCH_STRING' (current: 'null'): (?i)^(\s*)(TRUNCATE)

4

Provide a message for your check

This message should indicate that the check you are creating is triggered. You can type custom values, or press the Enter/Return key to use the default values.

CLI message:

Set 'MESSAGE' (current: 'A match for regular expression <SEARCH_STRING> was detected in Changeset <CHANGESET>.') (default "A match for regular expression <SEARCH_STRING> was detected in Changeset <CHANGESET>."):

In this example, we will use this as our message:

Table truncation detected. Review this changeset to ensure data is not unintentionally deleted.

5

The CLI will prompt you to review the table to confirm the customization

Customization complete. Review the table below to confirm your changes.

After you complete these tasks, the checks configuration displays for your review.

6

Add the following to the changelog.sql file and save your changes:

--changeset other.dev:4 labels:v0 context:all
truncate person;
7

Execute the checks run command

liquibase checks run
Customize a Policy check - Liquibase