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:
Database update commands
Command | Description |
---|---|
update command | Updates database to current version. |
updateSQL command | A helper command that allows you to inspect the SQL Liquibase will run while using the update command. |
updateCount <value> command | Applies the next <value> changesets. |
updateCountSQL <value> command | Writes SQL to apply the next <value> changesets to STDOUT . |
updateTestingRollback command | Updates the database, then rolls back changes before updating again. |
Database rollback commands
Command | Description |
---|---|
rollback <tag> command | Rolls back the database to the state it was in when the tag was applied. |
rollbackSQL <tag> command | A helper command that produces the raw SQL Liquibase would run when using the rollbackByTag command. |
rollbackToDate command | Rolls back the database to the state it was in at the given date/time. |
rollbackToDateSQL command | A helper command that allows you to inspect the SQL Liquibase will run while using the rollbackToDate command. |
rollbackCount <value> command | Rolls back the last <value> changesets. |
rollbackCountSQL <value> command | Writes SQL to roll back the last <value> changesets to STDOUT . |
rollbackOneChangeSet command | Rolls back a single changeset without needing to roll back other already applied changeset. Liquibase Pro Feature |
rollbackOneChangeSetSQL command | Writes SQL to roll back a single changeset to STDOUT . Liquibase Pro Feature |
rollbackOneUpdate command | Rolls back all changesets related by a specific deploymentId that was made during a previous change to your database. It is only available for Liquibase Pro users. |
rollbackOneUpdateSQL command | a helper command that allows you to inspect the SQL Liquibase will run to revert all changeset associated with the deploymentID specified in the rollbackOneUpdate command. It is only available for Liquibase Pro users. |
futureRollbackSQL command | Writes SQL to roll back the database to the current state after the changes in the changelog have been applied. |
updateTestingRollback command | Updates the database, then rolls back changes before updating again. |
Diff commands
Command | Description |
---|---|
generateChangeLog command | Generate a changelog from a database when adding Liquibase to a new project. Conceptually, does a diff of the current database to an empty database, creating a changelog that has all the changes needed to update an empty database. |
diff command | Writes description of differences between two databases to standard out. |
diffChangeLog command | Adds any differences between the databases specified to a changelog. Can append in any of the supported changelog formats. |
Documentation commands
Command | Description |
---|---|
dbDoc <outputDirectory> command | Generates Javadoc-like documentation based on current database and changelog. |
Maintenance commands
Command | Description |
---|---|
changelogSync command | Mark all changes as executed in the database. |
changelogSyncSQL command | Writes SQL to mark all changes as executed in the database to STDOUT . |
clearCheckSums command | 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. |
dropAll command | Drops all database objects owned by the user. DANGEROUS! |
listLocks command | Lists who currently has locks on the database changelog. |
markNextChangeSetRan command | Mark the next change set as executed in the database. |
releaseLocks command | Releases all locks on the database changelog. |
status --verbose command | Outputs count (list if --verbose) of changesets that have not been run. |
snapshot command | 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. |
tag <tag string> command | "Tags" the current database state for future rollback. |
tagExists <tag string> command | Checks whether the given tag already exists. |
validate command | Checks the changelog for errors. |
Liquibase Hub commands
Option | Description |
---|---|
registerChangeLog command | Connects your local Liquibase activity to a specific Liquibase Hub Project. |
syncHub command | Synchronizes the local DATABASECHANGELOG table with Liquibase Hub. |
Required parameters for most commands
Option | Description |
---|---|
--changeLogFile=<path and filename>
|
The changelog file to use. |
--username=<value>
|
Database username. |
--password=<value>
|
Database password. |
--url=<value>
|
Database JDBC URL. |
--driver=<jdbc.driver.ClassName>
|
Database driver class name. |
Optional parameters
Option | Description |
---|---|
--classpath=<value>
|
Classpath containing migration files and JDBC Driver. List multiple items using the standard path separator for your platform, which is a colon (:) on Mac/Linux, and a semicolon (;) on Windows. |
--contexts=<value>
|
changesets Contexts to execute. |
--defaultSchemaName=<schema>
|
Specifies the default schema to use for managed database objects and for Liquibase control tables. |
--databaseClass=<custom.DatabaseImpl>
|
Specifies a custom Database implementation to use |
--defaultsFile=</path/to/file>
|
File containing default option values. (default: ./liquibase.properties) |
--includeSystemClasspath=<true or false>
|
Include the system classpath in the Liquibase classpath. (default: true) |
--promptForNonLocalDatabase=<true or false>
|
Prompt if non-localhost databases. (default: false) |
--currentDateTimeFunction=<value>
|
Overrides current date time function used in SQL. Useful for unsupported databases. |
--labels=<value>
|
Filter the changelog using Labels. |
--logLevel=<level>
|
Execution log level (debug, info, warning, severe, off). |
--logFile=<filename>
|
Rather than logging to console, send logging messages to a file. |
--liquibaseProLicenseKey=<licenKey>
|
A Liquibase Pro license key (base64 encoded string) unlocks additional features. |
--help
|
Output command line parameter help. |
--dataOutputDirectory
|
Directory where insert statement csv files will be kept (required by generatechangelog command). |
--propertyProviderClass=<properties.ClassName>
|
Custom properties implementation to use |
--schemas=<name1,name2>
|
A comma-separated list of database schemas from which to include objects when executing a command, such as snapshot , generatechangelog , or diffchangelog . This flag is required when you are referencing multiple schemas in a command. |
Required diff parameters
Option | Description |
---|---|
--referenceUsername=<value>
|
Base Database username. |
--referencePassword=<value>
|
Base Database password. |
--referenceUrl=<value>
|
Base Database URL. |
Optional diff parameters
Option | Description |
---|---|
--referenceDriver=<jdbc.driver.ClassName>
|
Base Database driver class name. |
--referenceDefaultSchemaName=<schema>
|
Base Database default schema name. |
changelog properties
Option | Description |
---|---|
-D<property.name>=<property.value>
|
Pass a name/value pair for substitution of ${} blocks in the changelogs. |