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 Create and Configure a liquibase.properties File. 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: 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.

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 SQL output 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>

The tag identifying which tagged changesets in the changelog to evaluate.

Required