changelogSyncToTag command

The changelogSyncToTag command marks all undeployed changesets from your changelog up to the specified tag as executed in your database. The command also marks the changeset with that tag as deployed.

Note: If you don’t have any tag specified in your changelog file, add it by using the tagDatabase Change Type as follows:

<changeSet id="13.1" author="liquibase">
<tagDatabase tag="version_2.0"/>
</changeSet>

Uses

The changelogSyncToTag command is typically used when you want to baseline a new database environment with specific objects. An example use case for the changelogSyncToTag command is the following:

  1. You have a DEV environment with a set of objects used only in DEV, and you want to use the same changelog to manage a new TEST environment. The TEST environment does not have those DEV-only objects and needs only some of them.
  2. To deploy the needed DEV-only objects and avoid deploying the rest, you add a tag and run the changelogSyncToTag command to mark the changes related to that tag as executed in the DATABASECHANGELOG table.
  3. The command marks all changesets starting with the first changeset at the top of the DEV changelog file and moving down to the changesets up to and including the tag.
  4. Next, you deploy the changesets that were not marked as deployed in your database. Liquibase treats your DEV and TEST databases as equivalent.

Note: If you want to mark all undeployed changes from the changelog file as executed in your database, use the changelogSync command.

You can also use the changelogSyncToTag command to mark the change associated with a specific tag as executed if the object associated with the change was created manually on the database. By marking the changeset as executed, it prevents the next Liquibase update from failing as it tries to create an object that already exists.

Running the changelogSyncToTag command

Before running the changelogSyncToTag command, you can specify the driver, classpath, and URL in your liquibase.properties file. For more information, see Creating and configuring a liquibase.properties file. You can also specify these properties in your command line.

Next, run the changelogSyncToTag command:

liquibase --changelogFile=mychangelog.xml changelogSyncToTag version1

Note: Enter the name of the changelog and the tag that you want to use in place of mychangelog.xml and version1.

changelogSyncToTag global attributes

Attribute Definition Requirements
--changeLogFile The root changelog Required
--url The JDBC database connection URL Required
--username The database username Required
--password The database password Required

changelogSyncToTag command attributes

Attribute Definition Requirements
tag The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags. Required