Synchronize two environments using diff-changelog
Last updated: June 9, 2026
Use diff-changelog to synchronize two databases by generating a delta changelog that contains only the changes missing from the target.
Common scenarios include keeping staging and production in sync, or updating a local development instance to match a shared environment.
This differs from generate-changelog, which captures a full baseline from a single existing database and is typically a one-time step during onboarding.
Use diff-changelog on an ongoing basis as your reference environment continues to evolve.
Procedure
Take a snapshot of the target database.
Before generating a diff, capture the current state of your target database. This snapshot serves as the baseline for comparison.
Be sure to:
Replace
your_database_typewith your database type (for example, postgresql, mysql, or oracle)Replace
your_target_hostwith your target database hostname or IP addressReplace
your_portwith your target database portReplace
your_database_namewith your target database nameReplace
your_usernamewith your target database usernameReplace
your_passwordwith your target database password
Run diff-changelog to generate the delta changelog.
Compare the reference database (source of truth) against the snapshot of your target database. Liquibase will produce a changelog containing only the changes present in the reference that are missing from the target.
Be sure to:
Replace
your_working_directorywith the path to the directory where your snapshot file is savedReplace
your_database_typewith your database type (for example, postgresql, mysql, or oracle)Replace
your_reference_hostwith your reference database hostname or IP addressReplace
your_portwith your reference database portReplace
your_reference_databasewith your reference database nameReplace
your_reference_usernamewith your reference database usernameReplace
your_reference_passwordwith your reference database password
Note: You can find the correct JDBC URL format to use by referring to the article What databases are supported by Liquibase?
After the command runs, Liquibase automatically opens a Drift Report (HTML) in your browser showing the differences detected between the two databases.
Review the generated changelog.
Open sync-changelog.xml and verify that the changesets reflect only the expected differences. Confirm there are no unintended changes before deploying.
Deploy the changelog to the target database.
Once you’ve reviewed the changelog and it matches your expectations, apply the changes to the target database.
Be sure to:
Replace
your_working_directorywith the path to the directory where your changelog file is savedReplace
your_database_typewith your database type (for example, postgresql, mysql, or oracle)Replace
your_target_hostwith your target database hostname or IP addressReplace
your_portwith your target database portReplace
your_database_namewith your target database nameReplace
your_usernamewith your target database usernameReplace
your_passwordwith your target database password
After the command runs, Liquibase automatically opens an Update Report (HTML) in your browser summarizing which changesets were applied.
Commit the changelog to source control.
Add sync-changelog.xml to your version control system so the synchronization is tracked and reproducible.