Hi all! I’m doing some prototyping with respect to LB. One thing I wanted to ask is: How does LB do rollback of ALTER TABLE statements, especially when you are changing data types and adding/dropping columns?
What is the preferred method what rollback feature will allow you to reverse ALTER TABLE statements? Moreover if you could point me to some documentation, that would be appreciated. Thank you!
The second article contains a list of Liquibase changetypes and whether or not they support automatic rollbacks. Some general rules and best practices for working with rollback follow:
Automatic rollbacks only work with modeled changesets and NOT SQL or formatted SQL changests. Modeled changelog/changeset formats are XML, YML & JSON
For SQL/formatted SQL changesets and changetypes that don’t have an automatic rollback, you have to write your own rollback instructions. There are a variety of ways to do that described in the “Liquibase Rollback Workflow” document linked above.
We also recommend that you give the use of automatic rollbacks careful thought to avoid dataloss. The reverse of createTable is dropTable. In some cases this will work, but if the table has data in it you want to retain, you will need to provide specific rollback instructions to override the automatic behavior.
The two documents linked should contain everything you need to know. Good luck!
Pete, thank you very much! I will review these resources. Thank you very much for your prompt response and I will follow up if I have more questions! Have a great day.