The changelog-sync-to-tag 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"/>


The changelog-sync-to-tag command is typically used when you want to baseline a new database environment with specific objects. An example use case for the changelog-sync-to-tag 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 changelog-sync-to-tag 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 changelog-sync command.

You can also use the changelog-sync-to-tag 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 changelog-sync-to-tag command

Before running the changelog-sync-to-tag command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Specifying Properties in a Connection Profile. You can also specify these properties in your command line.

Next, run the changelog-sync-to-tag command:

liquibase --changelog-file=mychangelog.xml changelog-sync-to-tag version1

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

changelog-sync-to-tag global attributes

Tip: All commands and parameters use the --kebab-case format in the CLI environment. This is the format Liquibase recommends for best results. If your preference is camelCase, it will still work in the CLI.

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

Note: The username and password attributes are not required for connections and systems which use alternate means of authentication.

changelog-sync-to-tag 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

changelog-sync-to-tag example output

When successful, the changelog-sync-to-tag command produces the following output:

Liquibase Version: 4.9.1
Liquibase command 'changelog-sync-to-tag' was executed successfully.