tagDatabase

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

Tip: If you want to apply a tag to your database without modifying your changelog, use the tag command. To check whether a tag exists, use the tag-exists command.

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 tagDatabase changeset from your changelog, it adds a new row to the DATABASECHANGELOG table. This row will have the tag name specified in that changeset.

When you run the update-to-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 update-to-tag 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 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 run this Change Type, follow these steps:

  1. Add the Change Type to your changeset, as shown in the examples on this page.
  2. Specify any required attributes. Use the table on this page to see which ones your database requires.
  3. Deploy your changeset by running the update command:
  4. 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

Examples

tagDatabase is supported in formatted SQL changelogs in Liquibase Pro 4.29.2 and later.

--liquibase formatted sql

--changeset liquibase-docs:tagDatabase-example
--tagDatabase: 'version_1.3'
databaseChangeLog:
-  changeSet:
    id:  tagDatabase-example
    author:  liquibase-docs
    changes:
    -  tagDatabase:
        tag:  version_1.3
{
    "databaseChangeLog": [
        {
            "changeSet": {
                "id": "tagDatabase-example",
                "author": "liquibase-docs",
                "changes": [
                    {
                        "tagDatabase": {
                            "tag": "version_1.3"
                        }
                    }
                ]
            }
        }
    ]
}
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xmlns:pro="http://www.liquibase.org/xml/ns/pro"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
        http://www.liquibase.org/xml/ns/pro
        http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">

    <changeSet  author="liquibase-docs"  id="tagDatabase-example">
        <tagDatabase  tag="version_1.3"/>
    </changeSet>

</databaseChangeLog>

Database support

Database Notes Auto Rollback
DB2/LUW Supported Yes
DB2/z Supported Yes
Derby Supported Yes
Firebird Supported Yes
Google BigQuery 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
Snowflake Supported Yes
SQL Server Supported Yes
SQLite Supported Yes
Sybase Supported Yes
Sybase Anywhere Supported Yes