Liquibase "diff" Produces Empty or Wrong Changelog in CI
Liquibase diff/diffChangeLog compared two databases and produced nothing (or the inverse of what you wanted) because the reference and target were swapped, pointed at the wrong schema, or filtered objects out. This is a comparison-config issue, not a transient failure.
What this error means
liquibase diffChangeLog writes an empty changelog, or one that would drop instead of add objects. It is deterministic - the diff reflects exactly the two databases and schemas you pointed it at.
Diff Results:
Reference Database: app_target (target had the new tables)
Comparison Database: app_reference (reference was empty)
... generated changelog DROPS the new tables (reference/target swapped)Common causes
Reference and target databases swapped
Liquibase computes changes to turn the target into the reference. Swapping --referenceUrl and the target inverts the diff (drops instead of adds).
Wrong schema or default schema
Comparing the wrong schema (or relying on a default that differs between databases) yields an empty or misleading diff.
Object types excluded from the diff
A restrictive diffTypes/exclusion filter can drop the very objects you expected to see, leaving an empty changelog.
How to fix it
Set reference and target correctly
The reference is the desired/source-of-truth database; the target is the one to be changed. Generate the changelog from reference → target.
liquibase --referenceUrl=jdbc:postgresql://db:5432/app_desired \
--url=jdbc:postgresql://db:5432/app_current \
diffChangeLog --changeLogFile=diff.xmlVerify schemas and diff types
- Pass explicit
--defaultSchemaName/--referenceDefaultSchemaNameso both sides compare the same schema. - Avoid over-restrictive
diffTypesthat exclude tables/columns you need. - Review the generated changelog before running
updateagainst any real database.
How to prevent it
- Always confirm which database is reference vs target before diffing.
- Pass explicit schema names to both sides.
- Review generated changelogs; never auto-apply a diff unread.