Liquibase常见命令和参数一览表

所有命令和参数都使用--kebab-case格式。

liquibase <global arguments> <command> <command arguments>

备注:pro 角标是指需Liquibase专业版才支持。

1.Liquibase start commands

CommandDescription
init hubThe hub subcommand connects your local Liquibase activity to Liquibase Hub with an API key and sets up the Liquibase environment to use Liquibase Hub.
init projectThe project subcommand finds or creates your project folder with the changelog and Liquibase properties files and delivers an example H2 database to help you get started.
init start-h2The start-h2 subcommand starts the in-memory H2 database included in the Liquibase installation package to get started and test how Liquibase works.

2.Database update commands

CommandDescription
updateUpdates database to current version.
update-sqlA helper command that allows you to inspect the SQL Liquibase will run while using the update command.
update-countApplies the next <value> changesets.
update-count-sqlWrites SQL to apply the next <value> changesets to STDOUT.
update-testing-rollbackUpdates the database, then rolls back changes before updating again.
update-to-tagApplies sequential changes to your database from the newest changeset to the changeset with the tag you specified and applied earlier.
update-to-tag-sqlA helper command that inspects the SQL Liquibase will run while using the update-to-tag <tag> command.

3.Database rollback commands

CommandDescription
rollbackRolls back the database to the state it was in when the tag was applied.
rollback-sqlA helper command that produces the raw SQL Liquibase would run when using the rollbackByTag command.
rollback-to-dateRolls back the database to the state it was in at the given date/time.
rollback-to-date-sqlA helper command that allows you to inspect the SQL Liquibase will run while using the rollback-to-date command.
rollback-countRolls back the last <value> changesets.
rollback-count-sqlWrites SQL to roll back the last <value> changesets to STDOUT.
rollback-one-changesetproRolls back a single changeset without needing to roll back other already applied changeset.
rollback-one-changeset-sqlproWrites SQL to roll back a single changeset to STDOUT.
rollback-one-updateproRolls back all changesets related by a specific deploymentId that was made during a previous change to your database.
rollback-one-update-sqlproA 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-sqlWrites SQL to roll back the database to the current state after the changes in the changelog have been applied.
future-rollback-count-sqlGenerates 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-sqlProduces the raw SQL Liquibase would need to roll back all undeployed changes made up to the specified tag.

4.Database snapshot commands

CommandDescription
generate-changelogGenerate 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.
snapshotGathers 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-referenceCaptures the current state of the referenceURL database, which is the source database.

5.Database diff commands

CommandDescription
diffWrites description of differences between two databases to standard out.
diff JSONproAllows you to compare two databases of the same type, or different types, to one another and use the output in a JSON format.
diff-changelogAdds any differences between the databases specified to a changelog. Can append in any of the supported changelog formats.

6.Status commands

CommandDescription
historyLists all deployed changesets and their deploymentIds.
statusOutputs the count (or list, if --verbose) of changesets that have not been deployed.

7.Maintenance commands

CommandDescription
calculate-checksumCalculates and prints a checksum for the changeset with the specified id in the following format: filepath::id::author.
changelog-syncMarks all changes as executed in the database.
changelog-sync-sqlWrites SQL to mark all changes as executed in the database to STDOUT.
changelog-sync-to-tagMarks all undeployed changesets from your changelog up to and including the specified tag as executed in your database.
changelog-sync-to-tag-sqlProduces 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.
clear-checksumsRemoves 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.
drop-allDrops all database objects owned by the user.
execute-sqlExecutes a SQL string or file.
list-locksLists who currently has locks on the database changelog.
mark-next-changeset-ranMark the next change set as executed in the database.
mark-next-changeset-ran-sqlInspects the SQL Liquibase will run while using the mark-next-changeset-ran command.
release-locksReleases all locks on the database changelog.
tag“Tags” the current database state for future rollback.
tag-existsChecks whether the given tag already exists.
unexpected-changesetsProduces a list of changesets that were run in the database but do not exist in the current changelog.
validateChecks the changelog for errors.

8.Documentation commands

CommandDescription
db-docGenerates Javadoc-like documentation based on current database and changelog.

9.Liquibase Hub commands

OptionDescription
register-changelogConnects your local Liquibase activity to a specific Liquibase Hub Project.
sync-hubSynchronizes the local DATABASECHANGELOG table with Liquibase Hub.
deactivate-changelogRemoves the changelogID from your changelog file so it stops sending reports to Liquibase Hub.

10.Quality checks commands

CommandDescription
copyThe copy subcommand copies a customizable check so that you can run the same check multiple times with different parameters.
customizeThe customize subcommand allows you to customize checks specified in your check configurations.
deleteThe delete subcommand allows you to delete a copy of a check from your checks settings.
disableThe disable subcommand disables a specific check provided in the --check-name parameter.
enableThe enable subcommand enables a specific check provided in the --check-name parameter.
resetThe reset subcommand reverts customizations made to the check indicated in the --check-name parameter to default settings.
runThe run subcommand executes checks using the checks settings file and the changelog file you specify.
showThe show subcommand prints the available checks and their configurations as indicated in the check settings file to STDOUT.
bulk-setproThe bulk-set command sets all qualifying quality checks to the same value.

11.Required parameters for most commands

OptionDescription
--changelog-file=<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.

12.Optional parameters

OptionDescription
--classpath=<value>Additional JDBC Driver files that are not already in the $LIQUIBASE_HOME/lib or ./liquibase_libs directories. List multiple items using the standard classpath 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 is ./liquibase.properties).
--duplicateFileMode=</path/to/file>How to handle multiple files being found in the search path that have duplicate paths. Options are WARN (log warning and choose one at random) or ERROR (fail current operation).
--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)
--changelogParseMode=<value>Configures how to handle unknown fields in changelog files. Possible values: STRICT which causes parsing to fail, and LAX which continues with the parsing.
--currentDateTimeFunction=<value>Overrides current date time function used in SQL. Useful for unsupported databases.
--labels=<value>Filter the changelog using Labels.
--log-level=<level>Execution log level (debug, info, warning, severe, off).
--log-file=<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.
--helpOutput command line parameter help.
--dataOutputDirectoryDirectory where insert statement CSV files will be kept (required by generate-changelog 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 snapshotgenerate-changelog, or diff-changelog. This flag is required when you are referencing multiple schemas in a command.
--searchPath=<value>List of base directories and locations to search for migration files. List multiple items using commas (,). The default search path includes the current working directory plus any jars in your $LIQUIBASE_HOME/lib and ./liquibase_libs directories

13.Required diff parameters

OptionDescription
--referenceUsername=<value>Base Database username.
--referencePassword=<value>Base Database password.
--referenceUrl=<value>Base Database URL.

14.Optional diff parameters

OptionDescription
--referenceDriver=<jdbc.driver.ClassName>Base Database driver class name.
--referenceDefaultSchemaName=<schema>Base Database default schema name.

15.changelog properties

OptionDescription
-D<property.name>=<property.value>Pass a name/value pair for substitution of ${} blocks in the changelogs.

原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/experience/javae/16956.html

(0)
上一篇 2022年8月4日 00:54
下一篇 2022年8月9日 20:51

相关推荐

发表回复

登录后才能评论