Liquibase Commands
Liquibase comes with several commands that can help you migrate and make changes to your databases. The following is a list of all commands available:
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.
Liquibase init commands
Command | Description |
---|---|
init copy |
The |
init project |
The |
init start-h2 |
The |
Liquibase flow commands
Command | Description |
---|---|
flow
|
Creates portable, platform-independent Liquibase workflows that can run anywhere without modification. Flow allows you to put multiple commands in a single file, called a Flow File, so they can all run sequentially by typing a single command into the CLI. The |
flow validate
|
Validate a series of commands contained in one or more stages, as configured in a Liquibase flow file. |
Database update commands
Command | Description |
---|---|
drop-all | Drops all database objects owned by the user. |
execute-sql | Executes a SQL string or file. |
update | Updates database to current version. |
update-sql | A helper command that allows you to inspect the SQL Liquibase will run while using the update command. |
update-count | Applies the next <value> changesets. |
update-count-sql | Writes SQL to apply the next <value> changesets to STDOUT . |
update-one-changeset | Targets and deploys any single changeset. |
update-one-changeset-sql | Writes SQL to target and deploy any single changeset. |
update-testing-rollback | Updates the database, then rolls back changes before updating again. |
update-to-tag | Applies sequential changes to your database from the newest changeset to the changeset with the tag you specified and applied earlier. |
update-to-tag-sql | A helper command that inspects the SQL Liquibase will run while using the update-to-tag command. |
validate | Checks the changelog for errors. |
Database rollback commands
For information about how Liquibase rollbacks work, see Liquibase Rollback Workflow and Automatic and Custom Rollbacks.
Command | Description |
---|---|
rollback | Rolls back the database to the state it was in when the tag was applied. |
rollback-sql | A helper command that produces the raw SQL Liquibase would run when using the rollbackByTag command. |
rollback-to-date | Rolls back the database to the state it was in at the given date/time. |
rollback-to-date-sql | A helper command that allows you to inspect the SQL Liquibase will run while using the rollback-to-date command. |
rollback-count | Rolls back the last <value> changesets. |
rollback-count-sql | Writes SQL to roll back the last <value> changesets to STDOUT . |
rollback-one-changeset![]() |
Rolls back a single changeset without needing to roll back other already applied changeset. |
rollback-one-changeset-sql![]() |
Writes SQL to roll back a single changeset to STDOUT . |
rollback-one-update![]() |
Rolls back all changesets related by a specific deploymentId that was made during a previous change to your database. |
rollback-one-update-sql![]() |
A helper command that allows you to inspect the SQL Liquibase will run to revert all changeset associated with the deploymentID specified in the rollback-one-update command. |
future-rollback-sql | Writes SQL to roll back the database to the current state after the changes in the changelog have been applied. |
future-rollback-count-sql | Generates the SQL that Liquibase would use to sequentially revert the number of changes associated with undeployed changesets, which are added to a changelog file. |
future-rollback-from-tag-sql | Produces the raw SQL Liquibase would need to roll back all undeployed changes made up to the specified tag. |
Database inspection commands
Command | Description |
---|---|
diff | Writes description of differences between two databases to standard out. |
diff JSON | Allows you to compare two databases of the same type, or different types, to one another and use the output in a JSON format. |
diff-changelog | Adds any differences between the databases specified to a changelog. Can append in any of the supported changelog formats. |
generate-changelog | Generate a changelog from a database when adding Liquibase to a new project. This is synonymous with snapshot with the exception of saving the output as XML in the changelog. |
snapshot | Gathers the current database schema and displays that information to STDOUT . With options, can save the schema in JSON format, and that JSON snapshot can serve as a comparison database. |
snapshot-reference | Captures the current state of the referenceURL database, which is the source database. |
Change tracking commands
Command | Description |
---|---|
changelog-sync | Marks all changes as executed in the database. |
changelog-sync-sql | Writes SQL to mark all changes as executed in the database to STDOUT . |
changelog-sync-to-tag | Marks all undeployed changesets from your changelog up to and including the specified tag as executed in your database. |
changelog-sync-to-tag-sql | Produces the raw SQL that Liquibase would run when using the changelog-sync-to-tag command to mark all undeployed changesets associated with the specified tag as executed in your database. |
db-doc | Generates Javadoc-like documentation based on current database and changelog. |
history | Lists all deployed changesets and their deploymentIds . |
mark-next-changeset-ran | Mark the next change set as executed in the database. |
mark-next-changeset-ran-sql | Inspects the SQL Liquibase will run while using the mark-next-changeset-ran command. |
set-contexts | Sets or replaces contexts on your changesets using your command line. This is an alternative to setting contexts directly in your changelog. Liquibase 4.23.1+. |
set-labels | Sets or replaces labels on your changesets using your command line. This is an alternative to setting labels directly in your changelog. Liquibase 4.23.1+. |
status | Outputs the count (or list, if --verbose ) of changesets that have not been deployed. |
tag | "Tags" the current database state for future rollback. |
tag-exists | Checks whether the given tag already exists. |
unexpected-changesets | Produces a list of changesets that were run in the database but do not exist in the current changelog. |
Maintenance commands
Command | Description |
---|---|
calculate-checksum | Calculates and prints a checksum for the changeset with the specified id in the following format: filepath::id::author . |
clear-checksums | Removes current checksums from database. On next update changesets that have already been deployed will have their checksums recomputed, and changesets that have not been deployed will be deployed. |
list-locks | Lists who currently has locks on the database changelog. |
release-locks | Releases all locks on the database changelog. |
Quality checks commands
The following commands are subcommands of the checks
command. For more information, see Quality Checks. Quality checks are only available with Liquibase Pro.
Command | Description |
---|---|
bulk-set |
Sets all qualifying quality checks to the same value. |
copy |
Copies a customizable check so that you can run the same check multiple times with different parameters. Requires the |
customize |
Allows you to customize checks specified in your check configurations. Requires the |
delete |
Allows you to delete a copy of a check from your checks settings. You cannot delete static checks and parent dynamic checks used to create copies of checks. |
disable |
Disables a specific check provided in the |
enable |
Enables a specific check provided in the |
reset |
Reverts customizations made to the check indicated in the Note: When you reset a dynamic check that has been customized multiple times, the check reverts to its default settings, not to the previous customized settings. |
run |
Executes checks using the checks settings file and the changelog file you specify. Requires the |
show |
Prints the available checks and their configurations—as indicated in the checks settings file—to |