changelog-sync-to-tag
Last updated: September 2, 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:
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.
To deploy the needed DEV-only objects and avoid deploying the rest, you add a tag and run the
changelog-sync-to-tagcommand to mark the changes related to that tag as executed in the DATABASECHANGELOG table (DBCL).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.
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
tagDatabasein your changelog,changelog-sync-to-tagadds rows to the DBCL table for every changesetup to that tag.
If you omit
tagDatabasefrom your changelog,changelog-sync-to-tagadds rows to the DBCL table for all changes.If you misspell the tag from
tagDatabasewhen you run the command,changelog-sync-to-tagadds 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.
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 |
| The root changelog | Required |
| The tag identifying which tagged changesets in the changelog to evaluate. Specify as | Required |
| The JDBC database connection URL. | Required |
| 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 | Optional |
| Name of the default catalog to use for the database connection | Optional |
| Name of the default schema to use for the database connection. If Note: In the properties file and Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set | Optional |
| The JDBC driver class | Optional |
| The JDBC driver properties file | Optional |
| 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 to connect to the target database. | Optional |
| Username to connect to the target database. | 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.