changelog-sync

The changelog-sync command marks all undeployed changes in your changelog as executed in your database.

Uses

The changelog-sync command is typically used when you want to baseline a new database environment.

An example use case for the changelog-sync command is when 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 or need, those DEV-only objects. To avoid deploying the DEV-only objects, you run the changelog-sync command to mark those changes as executed in the DATABASECHANGELOG which tells Liquibase to treat these databases as equivalent.

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

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

Then run the changelog-sync command:

liquibase --changelog-file=mychangelog.postgresql.sql changelog-sync

Note: Enter the name of the changelog that you want to use in place of mychangelog.postgresql.sql.

changelog-sync global attributes

Tip: For best results, specify all commands and parameters with the --kebab-case format in the CLI. 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 example output

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

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