liquibase.precondition.Precondition implementations allow you to run validation and checks against your database before running a changelog as a whole, or before running individual changesets.


  • A check for a database-specific data structure

How to Create

Custom parsers must implement liquibase.precondition.Precondition, which includes the following methods:

public String getName();

Return the name used in XML and other changelogs to refer to the precondition.

public void check(Database database, DatabaseChangeLog changeLog) throws PreconditionFailedException, PreconditionErrorException;

Perform the check.  Throw a PreconditionFailedException if your precondition did not pass.  Throw a PreconditionErrorException if there was a problem evaluating your precondition.

Registering Custom Parsers

There are two ways to register a custom Preconditions:

  1. Create the class in a sub-package of "liquibase.precondition.ext".  Liquibase automatically registers Preconditions it finds in that package
  2. Call liquibase.precondition.PreconditionFactory.getInstance().register(yourPrecondition)

Threading/Singleton notes

Precondition implementations should be created thread safe.  Once an instance of a Precondition registered, PreconditionFactory will continue to use the same instance.