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>
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.
- 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: 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.
Before running the
changelog-sync-to-tag command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Create and Configure a liquibase.properties File. You can also specify these properties in your command line.
Next, run the
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
changelog-sync-to-tag global attributes
Tip: For best results, specify all commands and parameters in the
--kebab-case format in the CLI. If your preference is camelCase, it also works in the CLI.
The root changelog
The JDBC database connection URL
The database username
The database password
password attributes are not required for connections and systems which use alternate means of authentication.
changelog-sync-to-tag command attributes
The tag identifying which tagged changesets in the changelog to evaluate.
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.