What automatic rollbacks does Liquibase support?
Last updated: July 14, 2025
Liquibase supports multiple ways to revert your database to a previous state. For many Change types, such as createTable, addColumn, and renameColumn, Liquibase automatically generates the SQL statements necessary to complete the rollback, so you can simply run a command like rollback
on your desired changeset(s) and be done.
However, Liquibase cannot automatically generate rollback SQL for Change Types like dropTable and insert. To roll back database updates that include these changesets, you must write custom rollback statements in your desired changeset(s) and then run the rollback
command.
You must write custom rollback statements for all formatted SQL changelogs, as they do not support auto rollback, regardless of the Change Type. You can also write your own rollbacks if you want to override the default rollback statement for a Change Type that supports auto rollback.
For a complete list of Change Types that allow auto rollback, see the "Auto rollback Change Types" section.
Automatic rollback statements
When you run the update
command on a createTable
changeset, Liquibase executes the SQL statement CREATE TABLE myTable
. When you run the rollback
command to revert that changeset, Liquibase recognizes that the inverse of the original change is DROP TABLE myTable
and executes that statement. In this case, you aren't required to add anything special to your changelog.
Liquibase command 'rollback' was executed successfully. Liquibase: Rollback has been successful.
However, if you try to run rollback
on dropTable
, Liquibase cannot automatically generate the rollback SQL:
Unexpected error running Liquibase: No inverse to liquibase.change.core.DropTableChange created
There is only one state the database could be in right before a createTable
statement—a state in which the table does not exist. However, there are multiple states the database could be in right before a dropTable
statement, so Liquibase cannot reliably look through your changelog to "recreate" a table you dropped. This is because getting the table to its final state before being dropped may have involved a large number of changesets, raw SQL statements in sql
or modifySql
tags, Contexts, or manual changes to the changelog.
To roll back your dropTable
statement, you have to specify custom logic in your changelog so that Liquibase knows how to restore your database correctly.
Auto rollback Change Types
You can use an automatic rollback with XML, JSON, and YAML changelogs for any Change Type marked as "Supported" in the following table.
Change Type | Supported | Behavior |
| Not Supported | |
| Supported | Drop check constraint |
| Supported | Drop column |
| Supported | Drop default value |
| Supported | Drop foreign key constraint |
| Supported | Drop foreign key constraint and drop table |
| Supported | Drop not null constraint |
| Supported | Drop primary key |
| Supported | Drop unique constraint |
| Not Supported | |
| Not Supported | |
| Supported | Drop index |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Supported | Drop sequence |
| Supported | Drop synonym |
| Supported | Drop table |
| Not Supported | |
| Supported | Drop view |
| Not Supported | |
| Not Supported | |
| Supported | Enable check constraint |
| Supported | Enable trigger |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Supported | Add not null constraint |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Supported | Disable check constraint |
| Supported | Disable trigger |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Supported | Return empty change |
| Supported | Rename with |
| Supported | Rename with |
| Supported | Rename with |
| Supported | Rename with |
| Supported | Rename with |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Not Supported | |
| Supported | Deletes the tag |
| Not Supported |