rollbackToDateSQL
command
The rollbackToDateSQL
command is a helper command that allows you to inspect the SQL Liquibase will run while using the rollbackToDate command.
Uses
The rollbackToDateSQL
command is typically used when you want to inspect the raw SQL before running the rollbackToDate
command, so you can correct any issues that may arise before running the command.
Running the rollbackToDateSQL
command
Before running the rollbackToDateSQL
command, you can see the dates of all previous changes by running the history command.
Note: Unlike the rollbackToDate command, there is no impact to your database while using this command.
To run the rollbackToDateSQL
command, you need to specify your driver, class path, and 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.
Then run the rollbackToDateSQL
command:
liquibase --changeLogFile=postgres_lbpro_master_changelog.xml rollbackToDateSQL 2020-05-07
Note: Enter the name of the changelog and date you want to use in place of postgres_lbpro_master_changelog.xml
and 2020-05-07
.
rollbackToDateSQL
global attributes
Attribute | Definition | Requirement |
---|---|---|
--changeLogFile * |
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 |
--outputFile ** |
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, rollbackToDate
SQL output goes to STDOUT
.
rollbackToDate
command attributes
Attribute | Definition | Requirement |
---|---|---|
--date/time | The date and time your database rolls back to. The date format is YYYY-MM-DD HH:MM:SS or YYYY-MM-DD'T'HH:MM:SS, however, it is possible to indicate the date or time only. | Required |

Rolling Back Changeset:postgres_lbpro_master_changelog.xml::2::createTableforView-proschema::Liquibase Pro User
-- *********************************************************************
-- Rollback to 2020-05-07 Script
-- *********************************************************************
-- Change Log: postgres_lbpro_master_changelog.xml
-- Ran at: 5/8/20 10:21 AM
-- 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 (192.168.1.9)', LOCKGRANTED = '2020-05-08 10:21:02.286' WHERE ID = 1 AND LOCKED = FALSE;
-- Rolling Back ChangeSet: postgres_lbpro_master_changelog.xml::2::createTableforView-proschema::Liquibase Pro User
DROP TABLE "proschema"."account";
DELETE FROM "public"."databasechangelog" WHERE ID = '2::createTableforView-proschema' AND AUTHOR = 'Liquibase Pro User' AND FILENAME = 'postgres_lbpro_master_changelog.xml';
-- Release Database Lock
UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;