Customize a Policy check
*Last updated: July 18, 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.
Run this command in the CLI to create a copy of the check.
The copy of the check will become the customized policy check:
liquibase checks copy --check-name=SqlUserDefinedPatternCheck
Provide a short name for the Policy check
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 provide SqlTruncateCheck
as the short name, because we will be searching for any instances of Truncate
.
The CLI will indicate that the new check was created from SqlUserDefinedPattern
check successfully:
New check 'SqlTruncateCheck' created from 'SqlUserDefinedPatternCheck'
Provide a search string for the policy check to search for.
In this example, we will use TRUNCATE
because this check will search the database or changelog for the TRUNCATE
label.
Set 'SEARCH_STRING' (current: 'null'):
(?i)^(\s*)(TRUNCATE)
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.
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.
Add the following to the changelog.sql file and save your changes:
--changeset other.dev:4 labels:v0 context:all
truncate person;
Execute the checks run command
liquibase checks run