The futureRollbackSQL command is a helper command that produces the raw SQL Liquibase would need to roll back changes that have not yet been deployed to your database.


You can use the futureRollbackSQL command to inspect the raw SQL Liquibase would use to revert changes associated with undeployed changesets.

It is best practice to inspect SQL Liquibase would run when using the update command so you can review any changes the command would make to your database.

Note: The updateSQL command is a helper command that you can also use before running the update command. The main difference is that updateSQL creates objects associated with undeployed changesets, and futureRollbackSQL drops objects associated with undeployed changesets.

Running the futureRollbackSQL command

To run the futureRollbackSQL command, you can specify the driver, classpath, and URL in your liquibase.properties file. For more information, see Creating and configuring a liquibase.properties file. You can also specify these properties in your command line.

Then run the futureRollbackSQL command:

liquibase --changeLogFile=mychangelog.postgresql.sql --outputFile=future.txt futureRollbackSQL

Note: Enter the name of the changelog and output you want to use in place of mychangelog.postgresql.sql and future.txt.

futureRollbackSQL command attributes

Attribute Definition Requirement
--changeLogFile * Specifies the root changelog Required
--url Specifies the JDBC database connection URL Required
--username Specifies the database username Required
--password Specifies the database password Required
--outputFile ** Specifies the file path to where the rollback SQL will be written Optional

* Liquibase checks the changelog and any nested changelogs for the definitions of the changesets to roll back.

* * If not specified, the futureRollbackSQL output goes to STDOUT.

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

futureRollbackSQL example output

When successful, the futureRollbackSQL command produces the following output:

-- *********************************************************************
-- SQL to roll back currently unexecuted changes
-- *********************************************************************
-- Change Log: postgres_lbpro_master_changelog.xml
-- Ran at: 5/12/20 3:37 PM
-- Against: daticaluser1@jdbc:postgresql://localhost:5432/goku
-- Liquibase version: 3.8.10-DAT-4387-SNAPSHOT
-- *********************************************************************
-- Lock Database
UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'gemfire-PC (', LOCKGRANTED = '2020-05-12 15:37:53.101' WHERE ID = 1 AND LOCKED = FALSE;
-- Rolling Back ChangeSet: postgres_lbpro_master_changelog.xml::4::functionForTrigger::Liquibase Pro User
DROP FUNCTION "proschema".canned_spam CASCADE;
DELETE FROM "public"."databasechangelog" WHERE ID = '4::functionForTrigger' AND AUTHOR = 'Liquibase Pro User' AND FILENAME = 'postgres_lbpro_master_changelog.xml';
-- Release Database Lock