The future-rollback-sql 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 future-rollback-sql 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 update-sql command is a helper command that you can also use before running the update command. The main difference is that update-sql creates objects associated with undeployed changesets, and future-rollback-sql drops objects associated with undeployed changesets.

Running the future-rollback-sql command

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

Then run the future-rollback-sql command:

liquibase --changelog-file=mychangelog.postgresql.sql --output-file=future.txt future-rollback-sql

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

future-rollback-sql command attributes

Attribute Definition Requirement
--changelog-file * 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
--output-file ** 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 future-rollback-sql output goes to STDOUT.

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

future-rollback-sql example output

When successful, the future-rollback-sql 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