Introducing Agent Safe Governance for the AI Era

rollback

Last updated: July 9, 2026

The rollback command rolls back changes made to the database based on the specified tag.

Before you can use rollback, you need to have your Liquibase project set up. You'll need to make sure you have a liquibase.properties file that specifies the driver, classpath, and URL. You may also need to set up any needed authentication so Liquibase is connected to your database.

Uses

The rollback command is typically used to revert all changes that were made to the database after the tag you specify.

Liquibase provides significant value for managing rollbacks by creating a framework that encourages you to consider rollback scenarios during development, simplifies executing rollbacks with straightforward commands, and maintains a complete history of rollback operations for audit and troubleshooting purposes. We recommend that you write rollback logic for every changeset. You can use the RollbackRequired policy check to ensure that every changeset contains rollback logic.

Rollback and changelog format

If you are using formatted SQL changelogs, you must manually define rollback logic for all changesets. SQL changelogs do not support automatic rollback generation.

If you are using modeled changelogs (XML, YAML, JSON), Liquibase automatically generates rollback SQL for many change types, including createTable, renameColumn, and addColumn. For change types that do not support automatic rollback, you must define manual rollback logic. See What change types can I use auto rollback with? for a complete list.

Command behavior

When you run rollback, Liquibase will roll back sequentially all the deployed changes until it reaches the tag row in the DATABASECHANGELOG table. For example, you can use the rollback command when you want to undo a series of changes made to your database related to a specific tag such as a numbered release. If you have tags for release 1, release 2, and release 3, and need to make a correction in release 2, the rollback command will rollback release 3 first.

You must specify a tag with the tag command or the tagDatabase Change Type in your changelog file for rollback to work. If Liquibase cannot find your tag, it halts and displays the following message:

rollback: Unexpected error running Liquibase: Could not find tag 'doesntexist' in the database

Before running this command, it is best practice to run tag-exists to check whether your tag syntax is correct. It is also a best practice to copy and paste the name of the tag into the CLI so that you are less likely to misspell it.

The following image shows that if we deploy the createTable C changeset and run the rollback --tag=version1 command to revert changes, Liquibase will roll back only createTable C value:

newrollbackdiagram 518x277

In Liquibase Secure 4.27.0 and later, you can automatically generate a database Rollback Report summarizing this command.

Important: If you need to roll back a changeset that contains an error, perform the rollback before editing the changeset. Editing the changeset first causes a checksum mismatch, which prevents the rollback from executing.

Impact

Using the rollback command comes with risks to your database, so it's important to look for potential unintended consequences before executing it. You can do this with the rollback-sql command.

Destructive operations

For rollbacks that reverse destructive operations (DROP, DELETE, TRUNCATE), ensure that you maintain the data and implement logic for its recovery. The operation can be rolled back by recreating the objects, but the original data will not be restored.

To mitigate destructive operations, we recommend using policy checks. Depending on your use case, Liquibase offers several policy checks to assist you:

Tags and rollback

There are two ways to create a tag for rollback: the tag command and the tagDatabase Change Type. The tag command applies a tag to the last row in the DATABASECHANGELOG table. The tagDatabase Change Type creates a tag changeset directly in your changelog file.

The method you use affects how rollback behaves. When you roll back to a tag created with tagDatabase, rollback removes all deployed changesets after that tag row and the tag row itself. When you roll back to a tag applied with the tag command, only the deployed changesets are removed.

If you don't know a tag name, you can find existing tags in the DATABASECHANGELOG table.

liquibase rollback --tag=myTag --changelog-file=example-changelog.xml

Note: The --tag=myTag syntax was added in Liquibase 4.4. If you use an older version, specify your tag as a positional argument: <command> myTag.

Command parameters

Attribute

Definition

Requirement

--changelog-file=<string>

The root changelog

Required

--tag=<string>

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

--url=<string>

The JDBC database connection URL.

Required

--change-exec-listener-class=<string>

Fully-qualified class that specifies a ChangeExecListener.

Optional

--change-exec-listener-properties-file=<string>

Path to a properties file for the ChangeExecListener class.

Optional

--context-filter=<string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

--default-catalog-name=<string>

Name of the default catalog to use for the database connection

Optional

--default-schema-name=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

--driver=<string>

The JDBC driver class

Optional

--driver-properties-file=<string>

The JDBC driver properties file

Optional

--label-filter=<string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

--password=<string>

Password to connect to the target database.

Optional

--report-enabled=<true|false>

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

--report-name=<string>

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

--report-path=<string>

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

--report-suppress-exception=<true|false>

Liquibase 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

--report-suppress-sql=<true|false>

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

--rollback-script=<string>

The path to the script to use to perform the rollback. Only needed if the rollback is not already defined in the changelog, and if it is not a rollback statement that is automatically generated by Liquibase.

Optional

--tag-version=<string>

Tag version to use for multiple occurrences of a tag. Valid values are NEWEST and OLDEST. If set to NEWEST, Liquibase rolls back changes up to the most recent instance of the tag. Any older instances of the tag remain in the DATABASECHANGELOG table. If set to OLDEST, Liquibase rolls back changes up to the first instance of the tag. Default: OLDEST

Optional

--username=<string>

Username to connect to the target database.

Optional

Attribute

Definition

Requirement

cmdArgs: { changelog-file: "<string>" }

The root changelog

Required

cmdArgs: { tag: "<string>" }

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

cmdArgs: { url: "<string>" }

The JDBC database connection URL.

Required

cmdArgs: { change-exec-listener-class: "<string>" }

Fully-qualified class that specifies a ChangeExecListener.

Optional

cmdArgs: { change-exec-listener-properties-file: "<string>" }

Path to a properties file for the ChangeExecListener class.

Optional

cmdArgs: { context-filter: "<string>" }

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

cmdArgs: { default-catalog-name: "<string>" }

Name of the default catalog to use for the database connection

Optional

cmdArgs: { default-schema-name: "<string>" }

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

cmdArgs: { driver: "<string>" }

The JDBC driver class

Optional

cmdArgs: { driver-properties-file: "<string>" }

The JDBC driver properties file

Optional

cmdArgs: { label-filter: "<string>" }

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

cmdArgs: { password: "<string>" }

Password to connect to the target database.

Optional

cmdArgs: { report-enabled: "<true|false>" }

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

cmdArgs: { report-name: "<string>" }

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

cmdArgs: { report-path: "<string>" }

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

cmdArgs: { report-suppress-exception: "<true|false>" }

Liquibase 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

cmdArgs: { report-suppress-sql: "<true|false>" }

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

cmdArgs: { rollback-script: "<string>" }

The path to the script to use to perform the rollback. Only needed if the rollback is not already defined in the changelog, and if it is not a rollback statement that is automatically generated by Liquibase.

Optional

cmdArgs: { tag-version: "<string>" }

Tag version to use for multiple occurrences of a tag. Valid values are NEWEST and OLDEST. If set to NEWEST, Liquibase rolls back changes up to the most recent instance of the tag. Any older instances of the tag remain in the DATABASECHANGELOG table. If set to OLDEST, Liquibase rolls back changes up to the first instance of the tag. Default: OLDEST

Optional

cmdArgs: { username: "<string>" }

Username to connect to the target database.

Optional

Attribute

Definition

Requirement

liquibase.command.changelogFile: <string>

liquibase.command.rollback.changelogFile: <string>

The root changelog

Required

liquibase.command.tag: <string>

liquibase.command.rollback.tag: <string>

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

liquibase.command.url: <string>

liquibase.command.rollback.url: <string>

The JDBC database connection URL.

Required

liquibase.command.changeExecListenerClass: <string>

liquibase.command.rollback.changeExecListenerClass: <string>

Fully-qualified class that specifies a ChangeExecListener.

Optional

liquibase.command.changeExecListenerPropertiesFile: <string>

liquibase.command.rollback.changeExecListenerPropertiesFile: <string>

Path to a properties file for the ChangeExecListener class.

Optional

liquibase.command.contextFilter: <string>

liquibase.command.rollback.contextFilter: <string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

liquibase.command.defaultCatalogName: <string>

liquibase.command.rollback.defaultCatalogName: <string>

Name of the default catalog to use for the database connection

Optional

liquibase.command.defaultSchemaName: <string>

liquibase.command.rollback.defaultSchemaName: <string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

liquibase.command.driver: <string>

liquibase.command.rollback.driver: <string>

The JDBC driver class

Optional

liquibase.command.driverPropertiesFile: <string>

liquibase.command.rollback.driverPropertiesFile: <string>

The JDBC driver properties file

Optional

liquibase.command.labelFilter: <string>

liquibase.command.rollback.labelFilter: <string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

liquibase.command.password: <string>

liquibase.command.rollback.password: <string>

Password to connect to the target database.

Optional

liquibase.command.reportEnabled: <true|false>

liquibase.command.rollback.reportEnabled: <true|false>

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

liquibase.command.reportName: <string>

liquibase.command.rollback.reportName: <string>

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

liquibase.command.reportPath: <string>

liquibase.command.rollback.reportPath: <string>

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

liquibase.command.reportSuppressException: <true|false>

liquibase.command.rollback.reportSuppressException: <true|false>

 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

liquibase.command.reportSuppressSql: <true|false>

liquibase.command.rollback.reportSuppressSql: <true|false>

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

liquibase.command.rollbackScript: <string>

liquibase.command.rollback.rollbackScript: <string>

The path to the script to use to perform the rollback. Only needed if the rollback is not already defined in the changelog, and if it is not a rollback statement that is automatically generated by Liquibase.

Optional

liquibase.command.tagVersion: <string>

liquibase.command.rollback.tagVersion: <string>

Tag version to use for multiple occurrences of a tag. Valid values are NEWEST and OLDEST. If set to NEWEST, Liquibase rolls back changes up to the most recent instance of the tag. Any older instances of the tag remain in the DATABASECHANGELOG table. If set to OLDEST, Liquibase rolls back changes up to the first instance of the tag. Default: OLDEST

Optional

liquibase.command.username: <string>

liquibase.command.rollback.username: <string>

Username to connect to the target database.

Optional

Attribute

Definition

Requirement

JAVA_OPTS=-Dliquibase.command.changelogFile=<string>

JAVA_OPTS=-Dliquibase.command.rollback.changelogFile=<string>

The root changelog

Required

JAVA_OPTS=-Dliquibase.command.tag=<string>

JAVA_OPTS=-Dliquibase.command.rollback.tag=<string>

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

JAVA_OPTS=-Dliquibase.command.url=<string>

JAVA_OPTS=-Dliquibase.command.rollback.url=<string>

The JDBC database connection URL.

Required

JAVA_OPTS=-Dliquibase.command.changeExecListenerClass=<string>

JAVA_OPTS=-Dliquibase.command.rollback.changeExecListenerClass=<string>

Fully-qualified class that specifies a ChangeExecListener.

Optional

JAVA_OPTS=-Dliquibase.command.changeExecListenerPropertiesFile=<string>

JAVA_OPTS=-Dliquibase.command.rollback.changeExecListenerPropertiesFile=<string>

Path to a properties file for the ChangeExecListener class.

Optional

JAVA_OPTS=-Dliquibase.command.contextFilter=<string>

JAVA_OPTS=-Dliquibase.command.rollback.contextFilter=<string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

JAVA_OPTS=-Dliquibase.command.defaultCatalogName=<string>

JAVA_OPTS=-Dliquibase.command.rollback.defaultCatalogName=<string>

Name of the default catalog to use for the database connection

Optional

JAVA_OPTS=-Dliquibase.command.defaultSchemaName=<string>

JAVA_OPTS=-Dliquibase.command.rollback.defaultSchemaName=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

JAVA_OPTS=-Dliquibase.command.driver=<string>

JAVA_OPTS=-Dliquibase.command.rollback.driver=<string>

The JDBC driver class

Optional

JAVA_OPTS=-Dliquibase.command.driverPropertiesFile=<string>

JAVA_OPTS=-Dliquibase.command.rollback.driverPropertiesFile=<string>

The JDBC driver properties file

Optional

JAVA_OPTS=-Dliquibase.command.labelFilter=<string>

JAVA_OPTS=-Dliquibase.command.rollback.labelFilter=<string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

JAVA_OPTS=-Dliquibase.command.password=<string>

JAVA_OPTS=-Dliquibase.command.rollback.password=<string>

Password to connect to the target database.

Optional

JAVA_OPTS=-Dliquibase.command.reportEnabled=<true|false>

JAVA_OPTS=-Dliquibase.command.rollback.reportEnabled=<true|false>

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

JAVA_OPTS=-Dliquibase.command.reportName=<string>

JAVA_OPTS=-Dliquibase.command.rollback.reportName=<string>

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

JAVA_OPTS=-Dliquibase.command.reportPath=<string>

JAVA_OPTS=-Dliquibase.command.rollback.reportPath=<string>

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

JAVA_OPTS=-Dliquibase.command.reportSuppressException=<true|false>

JAVA_OPTS=-Dliquibase.command.rollback.reportSuppressException=<true|false>

Liquibase 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

JAVA_OPTS=-Dliquibase.command.reportSuppressSql=<true|false>

JAVA_OPTS=-Dliquibase.command.rollback.reportSuppressSql=<true|false>

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

JAVA_OPTS=-Dliquibase.command.rollbackScript=<string>

JAVA_OPTS=-Dliquibase.command.rollback.rollbackScript=<string>

The path to the script to use to perform the rollback. Only needed if the rollback is not already defined in the changelog, and if it is not a rollback statement that is automatically generated by Liquibase.

Optional

JAVA_OPTS=-Dliquibase.command.tagVersion=<string>

JAVA_OPTS=-Dliquibase.command.rollback.tagVersion=<string>

Tag version to use for multiple occurrences of a tag. Valid values are NEWEST and OLDEST. If set to NEWEST, Liquibase rolls back changes up to the most recent instance of the tag. Any older instances of the tag remain in the DATABASECHANGELOG table. If set to OLDEST, Liquibase rolls back changes up to the first instance of the tag. Default: OLDEST

Optional

JAVA_OPTS=-Dliquibase.command.username=<string>

JAVA_OPTS=-Dliquibase.command.rollback.username=<string>

Username to connect to the target database.

Optional

Attribute

Definition

Requirement

LIQUIBASE_COMMAND_CHANGELOG_FILE=<string>

LIQUIBASE_COMMAND_ROLLBACK_CHANGELOG_FILE=<string>

The root changelog

Required

LIQUIBASE_COMMAND_TAG=<string>

LIQUIBASE_COMMAND_ROLLBACK_TAG=<string>

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

LIQUIBASE_COMMAND_URL=<string>

LIQUIBASE_COMMAND_ROLLBACK_URL=<string>

The JDBC database connection URL.

Required

LIQUIBASE_COMMAND_CHANGE_EXEC_LISTENER_CLASS=<string>

LIQUIBASE_COMMAND_ROLLBACK_CHANGE_EXEC_LISTENER_CLASS=<string>

Fully-qualified class that specifies a ChangeExecListener.

Optional

LIQUIBASE_COMMAND_CHANGE_EXEC_LISTENER_PROPERTIES_FILE=<string>

LIQUIBASE_COMMAND_ROLLBACK_CHANGE_EXEC_LISTENER_PROPERTIES_FILE=<string>

Path to a properties file for the ChangeExecListener class.

Optional

LIQUIBASE_COMMAND_CONTEXT_FILTER=<string>

LIQUIBASE_COMMAND_ROLLBACK_CONTEXT_FILTER=<string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

LIQUIBASE_COMMAND_DEFAULT_CATALOG_NAME=<string>

LIQUIBASE_COMMAND_ROLLBACK_DEFAULT_CATALOG_NAME=<string>

Name of the default catalog to use for the database connection

Optional

LIQUIBASE_COMMAND_DEFAULT_SCHEMA_NAME=<string>

LIQUIBASE_COMMAND_ROLLBACK_DEFAULT_SCHEMA_NAME=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

LIQUIBASE_COMMAND_DRIVER=<string>

LIQUIBASE_COMMAND_ROLLBACK_DRIVER=<string>

The JDBC driver class

Optional

LIQUIBASE_COMMAND_DRIVER_PROPERTIES_FILE=<string>

LIQUIBASE_COMMAND_ROLLBACK_DRIVER_PROPERTIES_FILE=<string>

The JDBC driver properties file

Optional

LIQUIBASE_COMMAND_LABEL_FILTER=<string>

LIQUIBASE_COMMAND_ROLLBACK_LABEL_FILTER=<string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

LIQUIBASE_COMMAND_PASSWORD=<string>

LIQUIBASE_COMMAND_ROLLBACK_PASSWORD=<string>

Password to connect to the target database.

Optional

LIQUIBASE_COMMAND_REPORT_ENABLED=<true|false>

LIQUIBASE_COMMAND_ROLLBACK_REPORT_ENABLED=<true|false>

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

LIQUIBASE_COMMAND_REPORT_NAME=<string>

LIQUIBASE_COMMAND_ROLLBACK_REPORT_NAME=<string>

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

LIQUIBASE_COMMAND_REPORT_PATH=<string>

LIQUIBASE_COMMAND_ROLLBACK_REPORT_PATH=<string>

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

LIQUIBASE_COMMAND_REPORT_SUPPRESS_EXCEPTION=<true|false>

LIQUIBASE_COMMAND_ROLLBACK_REPORT_SUPPRESS_EXCEPTION=<true|false>

Liquibase 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

LIQUIBASE_COMMAND_REPORT_SUPPRESS_SQL=<true|false>

LIQUIBASE_COMMAND_ROLLBACK_REPORT_SUPPRESS_SQL=<true|false>

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

LIQUIBASE_COMMAND_ROLLBACK_SCRIPT=<string>

LIQUIBASE_COMMAND_ROLLBACK_ROLLBACK_SCRIPT=<string>

The path to the script to use to perform the rollback. Only needed if the rollback is not already defined in the changelog, and if it is not a rollback statement that is automatically generated by Liquibase.

Optional

LIQUIBASE_COMMAND_TAG_VERSION=<string>

LIQUIBASE_COMMAND_ROLLBACK_TAG_VERSION=<string>

Tag version to use for multiple occurrences of a tag. Valid values are NEWEST and OLDEST. If set to NEWEST, Liquibase rolls back changes up to the most recent instance of the tag. Any older instances of the tag remain in the DATABASECHANGELOG table. If set to OLDEST, Liquibase rolls back changes up to the first instance of the tag. Default: OLDEST

Optional

LIQUIBASE_COMMAND_USERNAME=<string>

LIQUIBASE_COMMAND_ROLLBACK_USERNAME=<string>

Username to connect to the target database.

Optional

For each changeset in your changelog, include rollback logic that defines the inverse operations. Your rollback instructions must be specific to the command you wish to roll back.

Single rollback statement example

This is an example of how you would create a rollback for creating a table by setting your rollback to drop the table, which is the reverse operation.

loading

loading

loading

loading

Multiple rollback statements example

For complex changesets that require multiple rollback operations, you can specify multiple rollback elements.

Understanding rollback order is important:

  • Within a single changeset:

    Rollback statements execute from top to bottom, in the order they appear.

  • Across a changelog file with multiple changesets:

    Changesets roll back from bottom to top, starting with the most recently deployed changeset and working backward to the oldest.

For example, if you deploy changesets 1, 2, and 3 in that order, a rollback operation processes them as 3, 2, 1.

Important: When writing multiple rollback statements within a changeset, list them in the order they should execute. In the example below, the foreign key constraint must be dropped before the table can be dropped, so the constraint rollback appears first.

loading

loading

loading

loading

Using external rollback files

For complex rollback logic like stored procedures, you can reference external rollback script files using --rollbackSqlFile. This approach is beneficial when rollback logic is extensive or when you want to keep rollback scripts organized in separate files.

In this example, you would replace my_path/my_rollback.sql with the path to a SQL file containing your rollback instructions for that changeset.

loading

loading

loading

loading

Directly reference changeset

The following example shows how you can use a <rollback> tag to reference the changeset that originally created a statement. This example uses changeset 2 to implement rollback logic against changeset 1:

loading

loading

loading

loading

Empty rollback statements

If you do not want to revert a change in a rollback mode, use either the keyword empty or the keyword not required inside the rollback tag. In XML, YAML, and JSON changelogs, you can also use an empty string inside the rollback tag.

You can also use an empty string (<rollback></rollback>) or a self-closing tag (<rollback/>).

loading

- changeSet: id: 1 author: liquibase changes: - createTable: tableName: testTable columns: - column: name: id type: int rollback: empty

You can also use an empty string (rollback: "") or an empty array (rollback: []).

{ "changeSet": { "id": 1, "author": "example", "changes": [ { "createTable": { "tableName": "testTable", "columns": [ { "column": { "name": "id", "type": "int" } } ] } } ], "rollback": "empty" } }

You can also use an empty string ("rollback": "") or an empty array ("rollback": []).

<changeSet id="3" author="liquibaseuser"> <createTable tableName="testTable"> <column name="id" type="int"/> </createTable> <rollback>empty</rollback> </changeSet>

You can also use an empty string (<rollback></rollback>) or a self-closing-tag (<rollback/>).

Output

When successful, the rollback command produces the following output:

Liquibase Version: 4.9.1 Rolling Back Changeset: example-changelog.sql::2::Amber.Williams Rolling Back Changeset: example-changelog.sql::1::Amber.Williams Liquibase command 'rollback' was executed successfully. Liquibase: Rollback has been successful.