Simplified icon of a shipping crate marked with code syntax

Stored Logic

Liquibase saves the current state of the database, including capturing schema structures such as tables, indexes, constraints, and data. Liquibase Pro goes beyond the open-source version by capturing additional stored logic objects.

Stored logic includes procedures, functions, packages, triggers, and other objects housed in the database to perform data-intensive logic operations that improve performance and security:

  • Performance because the logic is co-located with the data.
  • Security because the logic is embedded in the database and needs permission from the application to execute the logic.

Stored Logic in Liquibase

Change Types

For more information, see Change Types.

Commands

  • diff: compares two databases, including differences between stored logic objects in each.
  • diff-changelog: structures stored logic files into timestamped directories every time you run the command.
  • generate-changelog: creates a Liquibase changelog representing the current database state, including stored logic objets.
  • snapshot: captures the target database's current state, including stored logic objects.
  • snapshot-reference: captures the reference database's current state, including stored logic objects.

Parameters

(Optional) Versioning Stored Logic

Users can use the generate-changelog command to create a new version of the changelog file with stored logic objects based on the current database state.

Running the generate-changelog command with Liquibase Pro creates a directory called Objects within the directory where the command was run.

The Objects directory contains subdirectories for each of the stored logic types:

  • package
  • packagebody
  • function
  • stored procedure
  • trigger

Note: Some database platforms may not support all of these stored logic types.

The generate-changelog command will not create the Objects directory if:

  • You don't have a valid Liquibase Pro license key.
  • Stored logic is not present in the database.
  • The target database does not support the generate-changelog command and stored logic objects.
  • The changelog file is written in formatted SQL. The Objects folder can only be created when generating XML, JSON, or YAML changelogs.
  • There is a pre-existing directory called Objects that was created outside Liquibase.

Visit the generate-changelog command documentation page for troubleshooting tips when running this command for stored logic.

Related Content

Liquibase Resources

Liquibase Help

Visit the Liquibase Forum to ask questions, find answers from other Liquibase users, and learn about new Liquibase version releases.

Visit the Liquibase Support Portal for Liquibase Pro assistance and troubleshooting tips.