Purpose
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.
Examples
- A check for a database-specific data structure
How to Create
Custom parsers must implement liquibase.precondition.Precondition, which includes the following methods:
Code Block |
---|
public String getName();
|
Return the name used in XML and other changelogs to refer to the precondition.
Code Block |
---|
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:
- Create the class in a sub-package of "liquibase.precondition.ext". Liquibase automatically registers Preconditions it finds in that package
- Call liquibase.precondition.PreconditionFactory.getInstance().register(yourPrecondition)
Threading/Singleton notes
...
Content Moved
This content has moved to https://contribute.liquibase.com/code/api/precondition-precondition/