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


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

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.

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

Impact of running the rollback command

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

Running the rollback command

To run the rollback 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.

Also, before running the rollback command, you need to know the following:

  • If the tag name is unknown to you, you can find it in the DATABASECHANGELOG table.
  • If you don’t have any tags specified, you can run the tag command. If you run the tag command to mark the current database state or release, your tag will be applied to the last row in the DATABASECHANGELOG table.
  • If you use the tagDatabase Change Type to create a tag changeset in the changelog file and want to roll back changes applied after this tag, the rollback command will remove all changes made after this tag row and the tag row.
  • If you run the tag command, deploy changesets, and then add the tagDatabase Change Type in your changelog file, your changes and the tag row created by the tagDatabase Change Type will be removed till the command reaches the tag specified with the rollback command.
liquibase --changelog-file=dbchangelog.xml rollback version1

Note: Enter the name of your changelog and tag in place of dbchangelog.xml and version1.

rollback 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.

Attribute 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

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

rollback command attributes

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

Additional rollback functionality

  • Add custom rollback SQL to the changelog for any changesets which Liquibase cannot auto-generate rollback SQL. Liquibase cannot auto-generate rollbacks for SQL changelogs. Also, some Change Types have no corresponding rollback commands that can be automatically generated.
-- changeset liquibaseuser:1
create table Details1 ( id int primary key, name varchar(255) );
-- rollback drop table Details1;
  • Use an empty tag when you do not want to undo changes in a rollback mode.
<changeSet id="noRollback" author="liquibase">
  <createTable tableName="changeRollback">
    <column name="id" type="int"/>
  • Specify the rollback commands using the tag within the changeset tag when you want to override the default generated rollback commands. You can also specify multiple rollback.
<changeSet  author="liquibase"  id="30">
  <createTable tableName="table30">
    <column name="id" type="int"/>
    <column name="heading" type="varchar(36)"/>
    <column name="author" type="varchar(36)"/>
drop table table30

<changeSet id="multiRollbackTest" author="rs">
  <createTable tableName="multiRollback1">
    <column name="id" type="int"/>
  <createTable tableName="multiRollback2">
    <column name="id" type="int"/>
  <createTable tableName="multiRollback3">
    <column name="id" type="int"/>
drop table multiRollback1;
drop table multiRollback2;
<rollback>drop table multiRollback3</rollback>
  • Use the rollback to reference the changeset that originally created a statement.
<changeSet id="changeRollback2-drop" author="liquibase">
  <dropTable tableName="changeRollback2"/>
  <rollback changeSetId="changeRollback2-create" changeSetAuthor="liquibase"/>