Rollbacking - questions

Hi all
Am learning Liquibase and I have questions.
Rollback command has --changeLogFile and tag parameters. Why? F.e. I commited one script, made MyTag and commited  next 3 scripts. Then I assumed next 3 scripts were big big mistake and I need to rollback them all.

If I type

liquibase --driver=org.firebirdsql.jdbc.FBDriver --url=“SCHEDULE.FDB” --username=SYSDBA --password=masterkey rollback MyTag

liquibase answers me I have to point --changeLogFile param.  Well I point one of these 3 scripts and point MyTag too. So, liquibase rollbacks pointed script only? So what hell need I direct tag? Or maybe I do wrong?

It needs the changelog file in the rollback command because we don’t store the executed commands themselves, just the identifiers of which changeSets ran.  We need the changeLog file to figure out what needs to be rolled back and how.


I’d like to be sure of the behavior or rollback tag (executed from java, all initialized with change set file with applied changesets) for the following scenarios:

  1. Non-existent tag specified
    Expected: failure?

  2. Valid tag occurring after last change set from file.
    Expected: No change sets removed?

  3. Valid tag in position that would result in removed changesets, BUT there are other change newer change sets applied from other files.
    Expected: Should not allow rollback as it could break newer changes?

  4. Valid tag occurring at last change set from file.
    Expected: No change sets removed?
    What I see in practice:  Change sets are removed.

  5. Valid tag occurring somewhere in set of change sets from file.
    Expected: All changes post the tag will be removed?

  6. Valid tag occurring at last record before valid change sets from file.
    Expected: All changes from the file removed?

In my setup I tag the database before applying any liquibase change sets.
Then I apply a tag at the end of every change set.
I don’t care what the value of the previous change set is when I uninstall/rollback the change set, all I care about is that the changes from the current file removed and only if they don’t break newer changes.

Is there a reliable way of doing this?

We try to rollback changes in the reverse order they were applied, which may not correspond to the order in the file and doesn’t take into account file nesting.  The idea is that they were applied in a particular order and the safest way to undo them is using that same order but reversed.  If you have reordered or introduced new changeSets in the file before chagnes already ran, the rollback doesn’t take that into account.  I simply goes in reverse databasechangelog table order.

So, it should be:

  1. Failure
  2. no change sets removed
  3. rolls back changes after the tag was applied, regardless of the file it was defined in
  4. rolls back changes after the tag was applied, even if those changes occur before the tag in the file
  5. all changes (chronologically) after the tag are rolled back
  6. yes, assuming none of the changes were ran before.

By “apply a tag at the end of every change set” do you mean you have something like:


? If you are trying to use the tag to track which changeSets ran and roll them back individually, you should be able to just use the standard tracking of them in the databasechangelog table.