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.


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 futureRollbackSQL 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 updateSQL 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, you can specify the driver, classpath, and database 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.

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.