- Reference
- Version ยท 6.0.2
- Change Automation Reference
rollback-on-error
Last updated: November 17, 2026
--rollback-on-error is a Liquibase Secure command parameter that rolls a failed deployment back to the state the database was in before the operation started. The default value is false.
Uses
--rollback-on-error is a Liquibase Secure command parameter that controls what happens when a deployment fails partway through. Set it to true, and Liquibase stops at the changeset that failed and rolls back the changesets that had already deployed successfully in the same operation, returning the database to the state it was in before the operation started. The default value is false, which leaves those successful changesets in place. The parameter is available on update, update-count, update-to-tag, update-one-changeset, and update-testing-rollback. With update-testing-rollback, it covers a changeset that fails during either update pass, but not a failure during the rollback pass. Commands that only generate SQL, such as update-sql, do not accept it.
The changeset that failed is not itself part of that rollback. Liquibase rolls back what deployed, not what did not.
A changeset with failOnError set to false does not count as a failure. Liquibase ignores the error and continues the deployment, so --rollback-on-error has nothing to roll back. That changeset is not recorded as deployed, so it runs again on the next update.
Note: The rollback is all or nothing. If any changeset deployed in the same operation cannot be rolled back, because it has no <rollback> block and its changes have no automatic rollback, as with a sql change, Liquibase rolls back none of them. The command exits with code 1 and reports that at least one changeset in this deployment does not contain a rollback, and every changeset that deployed before the failure stays in place. Changesets deployed by an earlier operation do not count.
Rolling back the failed changeset's own changes
A changeset can still commit part of its work before it fails, and when that happens the database no longer matches the state it was in before the operation started. Liquibase runs the failed changeset's own <rollback> block whenever any of these is true:
runWithis set: The changeset runs through a native executor such assqlplusorpsql, which can report a failure after the database has already committed a statement.runInTransactionisfalse: Every statement in the changeset commits on its own, so the ones that ran before the failure are already durable.A statement in the changeset has already committed: On a database that commits statements on its own, a changeset that fails on a later statement has already committed the earlier ones. Liquibase runs the block in this case only when something in the failed changeset actually committed, so a changeset that fails on its first statement is left as it is.
Liquibase recognizes two groups of databases that commit statements on their own.
Oracle, MySQL, MariaDB, Snowflake, and Databricks: These databases commit each DDL statement as soon as it runs. DML statements stay inside the transaction, so a changeset that fails after running only DML statements has nothing committed, and its block does not run.
CockroachDB, Firebird, Sybase, Amazon Redshift, Google BigQuery, and Teradata: These databases cannot run DDL inside a transaction, so Liquibase runs every statement with autocommit on. Any statement that ran before the failure has already committed.
On Oracle, this includes a changeset that --oracle-fail-options stops because a stored object compiled with errors or warnings. The object was already created when the check stopped the changeset, so its <rollback> block runs.
In every other case the failure happened inside a transaction that was never committed, so the database already matches its pre-operation state and the block has nothing to undo. Liquibase reports that no deployed changesets were found to roll back, and does not run it. A changeset that has no <rollback> block is never rolled back this way, whichever of these conditions applies.
Example: rollback-on-error
liquibase update --changelog-file=example-changelog.sql --rollback-on-error=true
Syntax
You can set this parameter in the following ways:
Option | Syntax |
Command CLI parameter |
|
Liquibase properties file (defaults file) |
|
Command flow file argument (example) |
|
JVM system property (JAVA_OPTS environment variable) |
|
Liquibase environment variable |
|