Rollback multiple Update

We are running liquibase version 3.5 with Oracle. We are unable to perform rollbacks in liquibase ,against multiple update/insert operation in a single changesets.

 

Scenario is that we have list of multiple updates DMLs in a change-set that will update different tables when running liquibase command. But we did not yet conclude how to Perform Rollback in simple way.

Do we have to write a rollback query for each update command. If yes that’s mean if we have 100 updates so we have to write 100 Rollback queries against each Update statement.

 

Is there any solution or use case that we can follow and rollback using a single statement.

e.g. update Table set xyz='someValue' where ID=102;

so i want a rollback, please suggest i have 100 of queries like above

I don’t think that this is possible to do automatically.

First and foremost if you think of a generic rollback there needs to be information about the old state of the data you manipulated with the query. I your case it seems you changed one record with a given ID, but liquibase does not know the old value of your table, so no way to roll it back automatically. It gets even worse if you update multiple records with one statement, then there may be multiple values (each different in every record you update).

That is not possible to rollback automatically if you do not have a custom backup mechanism you may implement a semi automatic rollback, but this mechanic is not provided by liquibase.

What you can do is implement your own custom update/delete statement that does not only change a record but back it up for possible rollbacks and implement the rollback for that change too.

kind regards