tagDatabase

The tagDatabase Change Type applies a tag to the database for future update or rollback.

Uses

You can typically use the tagDatabase Change Type when you want to tag your current database state, release, or version, and then deploy new changesets to that tag or roll back changesets applied after that tag. If you deploy a Liquibase tagDatabase changeset from your changelog, it will add a new row to the DATABASECHANGELOG table. This row will have the tag name specified in that changeset.

When you run the updateToTag <tag> command or the Maven update goal with the liquibase.toTag attribute, and there is a row in the DATABASECHANGELOG table corresponding to the tagDatabase changeset in the changelog, the updateToTag command or the update Maven goal deploys all changesets starting with the first changeset at the top of the changelog file and moving down to the changeset up to the tag specified by the tagDatabase Change Type.

When you want to roll back changesets deployed after the tagDatabase Change Type, the rollback <tag> command or the Maven rollback goal with the liquibase.rollbackTag attribute will remove your changesets and the tagDatabase row specified with the rollback command or goal.

Note: The XSD doesn't allow the tagDatabase Change Type to be used with another Change Types in the same changeset.

Running the tagDatabase Change Type

To tag your current database state, release, or version, follow these steps:

Step 1: Add the tagDatabase Change Type to your changeset with the tag attribute 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 tag has been applied to the DATABASECHANGELOG table as a new changeset row.

Available attributes

Name Description Required for Supports
tag The tag to apply all all

Database support

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