Create a Custom policy check

Last updated: February 16, 2026

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 What is a Liquibase Pro Custom policy check?

For examples of more advanced Python scripts and guidance on writing Python code to use in the Liquibase policy checks framework, see What are some examples of Custom policy check scripts?

Before you begin

  • Liquibase Pro 4.29.0+

  • Configure a valid Liquibase Pro license key

  • Python 3.10.14+. See here for the official Python tutorial

  • Java Development Kit 17+ (available for Open JDK and Oracle JDK)

  • Linux, macOS, or Windows operating system

  • Ensure the Liquibase Checks extension is installed.

    • In Liquibase 4.31.0+, it is already installed in the /liquibase/internal/lib directory, so no action is needed.

    • If the checks JAR is not installed, download liquibase-checks-<version>.jar and put it in the liquibase/lib directory.

    • Or, if you use Maven, add this dependency to your pom.xml file: <dependency> <groupId>org.liquibase.ext</groupId> <artifactId>liquibase-checks</artifactId> <version>2.0.0</version> </dependency>

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.