rollbackOneChangeSet command reverts (rolls back) one non-sequential changeset made during a previous change to your database. It is only available for Liquibase Pro users.
rollbackOneChangeSet command is typically used when you want to undo a change made to your database and revert it to a previous state without affecting any other changes made to your database.
rollback command reverts all changesets deployed sequentially to a specified point by using
rollback <tag_name>, the
rollbackOneChangeSet command allows you to target a specific changeset without impacting changesets that came before or after it.
The image above shows changesets A through I, with changeset I being the most recently deployed. As you can see, the
rollbackOneChangeSet command allows you to target changeset B and revert it to its previous state without impacting the others.
The impacts of
Like any cherry-picking tool, using the
rollbackOneChangeSet command comes with risks which may be unintended.
Please look for potential unintended consequences before using this command.
It is a best practice to run the rollbackOneChangeSetSQL command because it allows you to inspect the rollback SQL and search for any potential mistakes before you execute
Also, the use of
rollbackOneChangeSet comes with risk of unintended consequences, because of this, the command requires a
--force flag to indicate that you intend to run the command.
Before running the
rollbackOneChangeSet command, gather the following information from your DATABASECHANGELOG table:
- The Author of the changeset you want to revert
- The changeset ID of the changeset you want to revert
- The file name (changeset path) of the changeset you want to revert
--rollbackScriptis only needed if the rollback is not already defined in the changelog, and if it is not a rollback that is automatically provided by Liquibase.
Then run the
rollbackOneChangeSet command, with your information:
For more command specific help, type
liquibase rollbackonechangeset --help into the command prompt.
rollbackOneChangeSet global attributes
||Specifies the root changelog.||Required|
||Specifies the JDBC database connection URL.||Required|
||Specifies the database username.||Required|
||Specifies the database password.||Required|
||Your Liquibase Pro license key||Required|
Note: The username and password attributes are not required for connections and systems which use alternate means of authentication.
rollbackOneChangeSet command attributes
||The changeset ID from the changelog.||Required|
||The name of the author for the changeset.||Required|
||The path to the changelog containing the changeset you want to rollback.||Required|
||A required parameter which indicates you intend to use this feature.||Required|
||The path to the script to use to perform the rollback.||Optional *|
* This option is only needed if the rollback is not already defined in the changelog, and if it is not a rollback that is automatically provided by Liquibase.
When successful, the
rollbackOneChangeSet command produces the following output: