future-rollback-from-tag-sql
The future-rollback-from-tag-sql
command is a helper command that produces the raw SQL Liquibase would need to roll back all undeployed changes made up to the specified tag.
Uses
You can use the future-rollback-from-tag-sql
command to inspect the raw SQL Liquibase would use to revert changes associated with undeployed changesets. It is similar to the future-rollback-sql
command, except that you can use the tag
attribute to exclude some undeployed changesets from the SQL output.
It is best practice to inspect the SQL Liquibase runs 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 use before running the update
command. The main difference is that update-sql
creates objects associated with undeployed changesets, and future-rollback-from-tag-sql <tag>
drops objects associated with undeployed changesets.
Running the future-rollback-from-tag-sql
command
To run the future-rollback-from-tag-sql
command, specify the driver, classpath, and database 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.
Using an XML, YAML, or JSON changelog, create a new changeset containing the tagDatabase
Change Type with the tag
attribute. Any undeployed changesets before and including the tag will be included in the SQL output, and any undeployed changesets after the tag will be excluded.
Then run the future-rollback-from-tag-sql
command:
liquibase --changelog-file=changelog.xml --output-file=future.txt future-rollback-from-tag-sql version_1.3
Note: Enter the name of the changelog and output you want to use in place of changelog.xml
and future.txt
.
future-rollback-from-tag-sql
global attributes
Attribute | Definition | Requirement |
---|---|---|
--output-file * |
Specifies the file path to where the rollback will be written | Optional |
*If not specified, future-rollback-from-tag-sql
output goes to STDOUT.
future-rollback-from-tag-sql
command attributes
Attribute | Definition | Requirement |
---|---|---|
--changelog-file * |
The root changelog | Required |
--url
|
The JDBC database connection URL | Required |
--username
|
The database username | Optional** |
--password
|
The database password | Optional** |
<tag>
|
The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags | Required |
*Liquibase checks nested changelogs for definitions of the changesets to rollback.
**Database credentials may be specified as independent username
and password
attributes or as part of the url
attribute.
Note: Liquibase does not require the username
and password
attributes for connections and systems which use alternate means of authentication.

-- *********************************************************************
-- SQL to roll back currently unexecuted changes
-- *********************************************************************
-- Change Log: changelog.xml
-- Ran at: 6/10/21, 1:59 PM
-- Against: DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev
-- Liquibase version: 4.4.0
-- *********************************************************************
-- Lock Database
UPDATE PUBLIC.DATABASECHANGELOGLOCK SET LOCKED = TRUE, LOCKEDBY = 'DESKTOP-IJRALVU (192.168.56.1)', LOCKGRANTED = '2021-06-10 13:59:49.307' WHERE ID = 1 AND LOCKED = FALSE;
-- Rolling Back ChangeSet: changelog.xml::3::adrian
DELETE FROM PUBLIC.DATABASECHANGELOG WHERE ID = '3' AND AUTHOR = 'adrian' AND FILENAME = 'changelog.xml';
-- Rolling Back ChangeSet: changelog.xml::2::adrian
DROP TABLE PUBLIC.company;
DELETE FROM PUBLIC.DATABASECHANGELOG WHERE ID = '2' AND AUTHOR = 'adrian' AND FILENAME = 'changelog.xml';
-- Release Database Lock
UPDATE PUBLIC.DATABASECHANGELOGLOCK SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
Liquibase command 'future-rollback-from-tag-sql' was executed successfully.