Create Rollback stage for Oracle Deployment

Hello,

We are setting up Liquibase for Oracle Deployment.

One question is how to create rollback ?

Eg: Deploy Pipeline has Create Table or Procedure, if i want to rollback what is the best way to configure in config.xml file ?

Hello, @madhukiran1988 - welcome to the Liquibase Community!

We have a couple of resources that you might find helpful:

If you still have questions after reviewing that material, please let us know!

Regards,
Tabby
Technical Community Manager

Just a word of advice - some changeset commands can be automatically rolled back by Liquibase, i.e. you do not have to specify a ‘rollback’ section in your XML file, it will know how to roll it back automatically. Other commands cannot be automatically rolled back, and a rollback operation will fail. Unfortunately this isn’t always obvious when you write the changeset and apply it. For example this happened to me today:

1/ Write a changeset that modifies a table by adding two columns.
2/ Apply the changeset to local dev database, works fine.
3/ Realise that I need to initialise the data in those columns, so…
4/ Rollback the changeset, works fine because addColumn support auto-rollback.
5/ Add a ‘update’ command in the changeset XML to update one column to a value.
6/ Apply the changeset, it works fine.
7/ Decide to park the feature for later, so issue a rollback command… it fails with:

Unexpected error running Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.UpdateDataChange created

Now, if you’ve rushed through development, added the ‘update’ command and seen it work, then happily commited your changes, pushed to production, and later try to rollback for whatever reason, you will be in a world of hurt because of the changeset.

It seems the fix in this situation is to add a ‘rollback’ section to the XML, but I am not sure if it’s possible to keep the auto-rollback nature of ‘addColumn’ while doing the rollback work for the ‘update’ myself. I think if you have a ‘rollback’ section, then none of the auto-rollback steps will be done automatically.

It’s worth noting that a more strict approach is to separate DDL statement (ones that modify schema, like ‘addColumn’) and data modification statements (like my ‘update’ that changes data) into separate changeSets. These can both exist in one changelog XML file. Then they have their own independent rollback logic, so you can keep the auto-rollback for the DDL statements and only have to specify the manual rollback work for the data modification statements.

See docs at Liquibase Auto Rollback | Liquibase Docs and the table headed “Using Change Types and auto rollback” to see which support it and which don’t.