Create a Custom policy check

Last updated: September 2, 2025

This tutorial shows you how to create, customize, and run a Liquibase custom policy check using a sample Python script. For a conceptual overview of this feature, see Liquibase Secure Custom Policy Checks.

For examples of more advanced Python scripts and guidance on writing Python code to use in the Liquibase policy checks framework, see Sample Custom Policy Check Scripts.

Before you begin

Tip: Downloading Python itself is not required to create custom checks in the Liquibase checks framework, but it may be useful to test checks against Python 3.10.14+.

Procedure

1

Create a new file in your Liquibase working directory or a subdirectory like /scripts.

This file will contain the Python script that is your custom policy check. In this example, we title our new file custom_check_no_tables.py.

2

Open the new custom_check_no_tables.py file and add the following custom policy check to it

loading

Note:Liquibase will run the check against every object in the database, so this script doesn't need a Python looping mechanism to iterate through database objects.

Create a custom policy check - Liquibase