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 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 tag your current database state, release, or version, follow these steps:

  1. Add the tagDatabase Change Type to your changeset with the tag attribute as it is shown in the examples.
  2. Deploy your changeset by running the update command:
  3. 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

<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>
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"
                        }
                    }
                ]
            }
        }
    ]
}

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
Snowflake Supported Yes
SQL Server Supported Yes
SQLite Supported Yes
Sybase Supported Yes
Sybase Anywhere Supported Yes