Rollback tag in postgresql

Hi, I am using tag command to rollback with xml formatted for postgesql, but it executes rollback with no errors and does absolutely nothing. Any idea what it could be? the rollbackCount command if it works and does the rollback correctly.

It will depend on what change-type you are trying to rollback. Not all change-types have “auto-rollback”. If a change-type does not have “auto-rollback” you will need to provide the rollback sql, something like this:

    DROP TABLE test_employee PURGE;

You can check whether a change-type has auto-rollback here:

1 Like

Thank you very much @daryldoak , but what is happening to me is that when I execute rollbackCount, the rollback works perfect, but when I execute rollback , after excecute tag , doesn’t work. I find it weird that rollback doesn’t work like this, any ideas?

Hello @ilasso

Could you please help us with the command you are using? Are you rolling back only single changeset (count =1)?

Also please shre the Liquibase version you are using for this execution.

Rakhi Agrawal

thanks @rakhi ,

  1. liquibase update --log-level flag --log-file=update.log
  2. liquibase tag sprint01_01
  3. liquibase rollback spring01_01 --log-file=rollbackTag.log --log-level=DEBUG

Liquibase Version: 4.4.3
Liquibase Community 4.4.3 by Datical

If it is happening to me in this case with only one change set, but before I also had other changesets but I eliminated them because I thought it was in one of them, in this case it is a CREATE TABLE.

Right now I used an additional changeset with Database tag at the start of the changelog and it worked for me. However I thought it should work without having to define the tagDatabase.

Thanks @ilasso for the details.

From what you shared, I understand that you are following below steps-

  1. Liquibase update (executing various changesets)
  2. Liquibase tag (tagging this state of database as say “sprint01_01”)
  3. Liquibase rollback to tag “sprint01_01”.

Please correct me if I understand this wrong.

If I understand it correct, then Liquibase is actually rolling back to tag “sprint01_01”. A tag acts like a checkpoint to which you can anytime rollback your database to. Read more about it here.

Let’s assume, you have executed following steps -

  1. Liquibase update (executing various changesets)
  2. Liquibase tag (tagging this state of database as say “sprint01_01”)
  3. Liquibase update (executing further changesets)
  4. Liquibase rollback to tag “sprint01_01”.

In this case when you perform “Liquibase rollback to ‘sprint01_01’”, then Liquibase will undo all the changesets executed as a part of step 3.

However in your case Liquibase doesn’t find any changesets to undo while rolling back to tag “sprint01_01”. You could maybe try something like this -

  1. Liquibase tag “sprint01_start”
  2. Liquibase update (executing various changesets)
  3. Liquibase tag (tagging this state of database as say “sprint01_00”)
  4. Liquibase update (executing further changesets)
  5. Liquibase tag (tagging this state of database as say “sprint01_01”)
  6. Liquibase rollback to tag “sprint01_00”.

This will rollback and get your DB at state after step 2.

Please let us know if any other queries.

Rakhi Agrawal

1 Like

You’re right @rakhi , I was using it wrong, the command tag goes first, Thank you very much.


No worries. Happy to help!