changelog-sync-to-tag

Last published July 28, 2025

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"/> </changeSet>

Uses

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 (DBCL).

  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: Use the changelog-sync command to mark all undeployed changes from the changelog file as executed in your database.

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. Marking the changeset as executed prevents the next Liquibase update from failing as it tries to create an object that already exists.

Command behavior

You must specify a tag with the tagDatabase Change Type in your changelog file for changelog-sync-to-tag to work:

  • If you specify tagDatabase in your changelog, changelog-sync-to-tag adds rows to the DBCL table for every changeset

    up to that tag.

  • If you omit tagDatabase from your changelog, changelog-sync-to-tag adds rows to the DBCL table for all changes.

  • If you misspell the tag from tagDatabase when you run the command, changelog-sync-to-tag adds rows to the DBCL table for all changes.

If Liquibase cannot find your tag, it displays the following message:

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

Tip: Before running this command, it is best practice to run tag-exists to check whether your tag syntax is correct. It is also a best practice to copy and paste the name of the tag into the CLI so that you are less likely to misspell it.

Syntax

Before running the changelog-sync-to-tag command, specify the driver, classpath, and URL in the Liquibase properties file. You can also specify these properties in your command line.

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

liquibase changelog-sync-to-tag --tag=myTag --changelog-file=example-changelog.xml

Note: The --tag=myTag syntax was added in Liquibase 4.4. If you use an older version, specify your tag as a positional argument: <command> myTag.

Note: The username and password attributes are not required for connections and systems that use alternate authentication methods. Also, you can specify database credentials as part of the url attribute.

Command parameters

Attribute

Definition

Requirements

--changelog-file=<string>

The root changelog

Required

--tag=<string>

The tag identifying which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

--url=<string>

The JDBC database connection URL.

Required

--context-filter=<string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

--default-catalog-name=<string>

Name of the default catalog to use for the database connection

Optional

--default-schema-name=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

--driver=<string>

The JDBC driver class

Optional

--driver-properties-file=<string>

The JDBC driver properties file

Optional

--label-filter=<string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

--password=<string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--username=<string>

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

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.