rollback-sql

The rollback-sql tag is a helper command that produces the raw SQL Liquibase would run when using the rollback command.

Uses

The rollback-sql command is typically used to inspect the SQL Liquibase uses to revert changes associated with a tag you specify when you run the rollback command. It is best practice to use the rollback-sql command before running the rollback command to ensure that you eliminate any potential risks.

Running the rollback-sql command

To run the rollback-sql command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Specifying Properties in a Connection Profile. You can also specify these properties in your command line.

Then run the rollback-sql command:

liquibase --changelog-file=changelog.xml rollback-sql myTag

Note: Enter the name of the changelog and tag that you want to use in place of changelog.xml and myTag.

rollback-sql global attributes

Tip: All commands and parameters use the --kebab-case format in the CLI environment. This is the format Liquibase recommends for best results. If your preference is camelCase, it will still work in the CLI.

Attributes Definition Requirement
--changelog-file* The root changelog Required
--url The JDBC database connection URL Required
--username The database username Required
--password The database password Required
--output-file** Specifies the file path to where the rollback will be written Optional

* Liquibase checks nested changelogs for definitions of the changesets to rollback.

**If not specified, rollback-sql output goes to STDOUT.

Note: The username and password attributes are not required for connections and systems which use alternate means of authentication.

rollback-sql command attributes

Attribute Definition Requirement
<tag> Tags allow the user to identify which changesets in the changelog to evaluate. Required