future-rollback-from-tag-sql

Last published July 28, 2025

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.

You must specify a tag with the tag command or the tagDatabase Change Type in your changelog file for future-rollback-from-tag-sql to work. If Liquibase cannot find your tag, it halts and displays the following message:

future-rollback-from-tag-sql: Unexpected error running Liquibase: No tag matching 'doesntexist' found

Tip: Before running this command, it is best practice to run tag-exists to check whether your tag syntax is correct. It is also a best practice to copy and paste the tag name into the CLI so that you are less likely to misspell it.

Tip: When you run future-rollback-from-tag-sql, check whether you specified the correct tag and whether any changesets were rolled back. (If you specify a tag Liquibase cannot find in your changelog, the rollback command halts.)

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=<tag> drops objects associated with undeployed changesets.

Syntax

To run the future-rollback-from-tag-sql command, specify the driver, classpath, and database URL in the Liquibase properties file. . 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 future-rollback-from-tag-sql --tag=myTag --changelog-file=example-changelog.xml --output-file=example-file.txt

Note: The --tag=myTag syntax was added in Liquibase 4.4. If you use an older version, specify your tag as a positional argument: <command> myTag.

*Liquibase checks nested changelogs for definitions of the changesets to rollback.

Note: The username and password attributes are not required for connections and systems that use alternate means of authentication. Also, you can specify database credentials as part of the url attribute.

Parameters

Global parameters

Attribute

Definition

Requirement

--output-file=<string>

File path to where the command output will be written. If not specified, output goes to STDOUT. See --output-file.

Optional

Command parameters

Attribute

Definition

Requirement

--changelog-file=<string>

The root changelog

Required

--tag=<string>

The tag identifies which tagged changesets in the changelog to evaluate. Specify as --tag=myTag. Positional format <command> <tag> deprecated in 4.4+.

Required

--url=<string>

The JDBC database connection URL.

Required

--context-filter=<string>

Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run.

Note: If you use Liquibase 4.23.0 or earlier, use the syntax --contexts instead of --context-filter.

Optional

--default-catalog-name=<string>

Name of the default catalog to use for the database connection

Optional

--default-schema-name=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

--driver=<string>

The JDBC driver class

Optional

--driver-properties-file=<string>

The JDBC driver properties file

Optional

--label-filter=<string>

Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run.

Optional

--output-default-catalog=<true|false>

Control whether names of objects in the default catalog are fully qualified or not. If true, they are. If false, only objects outside the default catalog are fully qualified. Default: true.

Optional

--output-default-schema=<true|false>

Control whether names of objects in the default schema are fully qualified or not. If true, they are. If false, only objects outside the default schema are fully qualified. Default: true.

Optional

--password=<string>

Password to connect to the target database.

Tip: It is best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--username=<string>

Username to connect to the target database.

Tip: It is best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Output

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

future-rollback-from-tag-sql - Liquibase