Database Inspection Commands
The purpose of the database inspection commands is to allow users to compare differences between databases and between snapshots of one database over time.
Database Inspection Category
These commands are available in all Liquibase editions.
diff
: use this to compare two databases or compare changes in one database over time. The command helps users detect drift between a model schema and a database's actual schema. It's also used to identify missing database objects or unexpected items.diff-changelog
: use this to create a deployable changelog to synchronize multiple databases. The command is also used to identify missing database objects or unexpected items.snapshot
: use this to capture the current state of the target database where commands are executed. The command can also be used to compare a previous database state to another snapshot.snapshot-reference
: use this to capture the current state of the source database (--reference-url
).generate-changelog
: use this to create a changelog file that captures the current state of a database. The changelog can be used to apply changes to another database where Liquibase has not been used before.
Additional Commands for Liquibase Pro
These commands require an active Liquibase Pro license:
diff JSON
: use this to detect drift between a model schema and a database's actual schema using the diff command with the command output in a machine-readable JSON file, which can be used as an input to automated processes.
Each individual database inspection command page specifies the criteria for using the command successfully, including a list of required and optional command-specific arguments.
Database Inspection Command Requirements
All inspection commands require the following command argument:
- The JDBC database connection URL is specified as
--url
. This represents the target database where commands are executed.
The diff
, diff-changelog
, and diff
JSON commands also require the following command argument:
- The reference JDBC database connection URL is specified as
--reference-url
. This represents the source database used to compare to the target database.
Your source and target databases may also require the --username
and --password
arguments in Liquibase. However, the username and password are not required for connections and systems which use alternate means of authentication.
Troubleshooting
If Liquibase returns an error when you run a database inspection command, use the Liquibase --help
parameter to check the correct syntax of the command and the command-specific parameters you can use with it.
For example, in the CLI:
liquibase <command> --help
Related Content
- Visit the Using JDBC URL in Liquibase documentation page to learn more about Liquibase database connection requirements.
- Visit the Liquibase Pro Drift Report documentation page to learn more about generating a drift detection operation report using the
diff
anddiff-changelog
commands. Requires an active Liquibase Pro license and Liquibase version 4.25.0 and later (diff
) or 4.25.1 and later (diff
anddiff-changelog
).
Liquibase Resources
Liquibase Help
Visit the Liquibase Forum channel to ask questions, find answers from other Liquibase users, and learn about new Liquibase version releases.
Tutorials
- Visit the Diffing Multiple Schemas in Liquibase documentation page to learn more about best practices and a review of a typical workflow using the inspection commands.
- Visit the How to set up Liquibase with an Existing Project and Multiple Environments documentation page to learn how to use the
generate-changelog
command to set up Liquibase on multiple environments.
Liquibase University
Fundamentals of Liquibase: this course includes, but is not limited to, an introduction to the diff
and snapshot
commands.
Blogs and Articles
- Detecting Database Changes to Improve Security and Quality: read this tips and tricks blog on why inspecting databases is useful and using Liquibase inspection commands to compare database states.
- Comparing Two States of the Same Database Schema: read this tips and tricks blog on the workflow steps to compare two database schema states.
- Best Practices for Using Diffs: read this tips and tricks blog for when diff commands are useful and considerations before using these commands.