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.

Syntax

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 Create and Configure 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 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.

Global arguments

Tip: For best results, specify all commands and parameters in the --kebab-case format in the CLI. If your preference is camelCase, it also works in the CLI.

Attribute Definition Requirement
--output-file

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

Optional

Command arguments

Attribute Definition Requirement
--changelog-file*

The root changelog

Required
--tag

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

Required
--url

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required
--context-filter

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

Name of the default catalog to use for the database connection

Optional
--default-schema-name

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.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional
--driver

The JDBC driver class

Optional
--driver-properties-file

The JDBC driver properties file

Optional
--label-filter

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

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

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

Password to connect to the target database.

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

Optional
--username

Username to connect to the target database.

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

Optional

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

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