Skip to content
Latchkey

liquibase rollback: Undo Changesets by Tag

liquibase rollback reverts applied changesets back to a named tag, and rollbackCount reverts a fixed number of them.

Rollback undoes changes using the rollback logic defined in each changeset. It only works if those changesets have rollback statements or auto-derivable ones.

What it does

liquibase rollback <tag> reverts every changeset applied after that tag, in reverse order, using each changeset rollback block. rollbackCount <n> reverts the last n changesets and rollbackToDate reverts to a timestamp.

Common usage

Terminal
# revert everything applied after the "release-1.4" tag
liquibase --changelog-file=db/changelog.xml \
  --url=jdbc:postgresql://db:5432/app \
  --username=ci --password="$DB_PASSWORD" \
  rollback release-1.4

# revert the last 2 changesets
liquibase --changelog-file=db/changelog.xml rollbackCount 2

Options

Command / flagWhat it does
rollback <tag>Revert changesets applied after the tag
rollbackCount <n>Revert the last n applied changesets
rollbackToDate <date>Revert changesets applied after a date/time
--changelog-file=<path>Changelog containing the rollback logic
tag <name>Companion command that creates a rollback point

In CI

Tag the database (liquibase tag <name>) before a deploy so you have a precise rollback point. Rollback only works when changesets carry rollback statements; changes like arbitrary SQL need an explicit <rollback> block or the command fails.

Common errors in CI

"No rollback script found and no auto-rollback ... for changeSet" means a changeset lacks rollback logic; add a <rollback> block. "Could not find tag 'X' in the database" means the tag was never created with liquibase tag. Lock errors ("Could not acquire change log lock") mean a stuck DATABASECHANGELOGLOCK; run liquibase releaseLocks.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →