createTrigger

The createTrigger Change Type creates the trigger in a database.

Uses

You can typically use the createTrigger Change Type when you want to add a trigger to the table which will be automatically activated when a specific event occurs in your database. It can include catalog, schema, and table name attributes listed in this documentation.

Running the createTrigger Change Type

To create a trigger in your database, follow these steps:

Step 1: Add the createTrigger Change Type to your changeset with the needed attributes as it is shown in the examples.

Step 2: Deploy your changeset by running the update command.

liquibase update

Now, you should see that the trigger you've specified is added.

Available attributes

Name Description Required for Supports Since
catalogName The name of the catalog. asany, db2, db2z, derby, firebird, h2, hsqldb, informix, ingres, mariadb, mysql, oracle, postgresql, sqlite, sybase
comments Comments you can add to the trigger. all
dbms The logical expression of database type(s) on which the change must be applied. Valid database type names are listed on the supported databases page. You can specify the following:
  • A comma-separated list of multiple databases.
  • A change that is not applicable to a particular database type by prefixing with !.
  • The keywords all and none.
all 3.1
disabled Disables the trigger. all
encoding You can use this in a file defined in the path attribute. all
path The file containing the procedure text. You need to specify the path attribute or a nested procedure text. all all
procedureText The SQL creating the procedure. You need to specify the procedureText or the path attribute. all all
relativeToChangelogFile Defines whether the file path is relative to the root changelog file rather than to the classpath. all
replaceIfExists Alters the stored procedure defined by procedureName if it already exits. all
schemaName The name of the schema. all
scope The name of the module for a trigger. all
tableName The name of the table. all
triggerBody The body of the trigger. all all
triggerName The name of the trigger to create. all all

Database support

Database Notes Auto rollback
DB2/LUW Supported No
DB2/z Supported No
Derby Supported No
Firebird Supported No
H2 Supported No
HyperSQL Supported No
INGRES Supported No
Informix Supported No
MariaDB Supported No
MySQL Supported No
Oracle Supported No
PostgreSQL Supported No
SQL Server Supported No
SQLite Supported No
Sybase Supported No
Sybase Anywhere Supported No