4 ms·
Schema rollback doesn't really work, because once you have data in the database DROP TABLE is not the inverse of CREATE TABLE (going back and forth deletes the
by pornel 13y ago
Schema rollback doesn't really work, because once you have data in the database DROP TABLE is not the inverse of CREATE TABLE (going back and forth deletes the data).
I've never been in situation where losing production data is acceptable. I've stopped bothering with rollback statements that nobody ever cares to test and nobody will ever use in production. Schema changes are forward-only.
- toxicFork 13y agoAssuming you have lots of storage space, instead of drop you could just copy the table across to the archive. Similarly with dropped fields' previous versions, and created fields' current versions in the case of a rollback. But then you will also need to have the logic to create those fields for new rows. It's just easier to have forwards-only changes.
- mediascreen 13y agoI don't do rollback statements for non reversible operations either, but for some things like adding/renaming columns or adding/dropping indices it usually works fine.
- radiowave 13y agoThat's true, but I still test the rollback on all my liquibase change sets. This helps to ensure that I have a straightforward option to back out of my changes solely in the case that something goes badly wrong immediately during deployment into the live environment. But I agree that any regression after that point requires independent consideration, for the reasons you give.
- share_and_enjoy 13y agoAgree with the production use case. For me rollback scripts are more useful in development and branching than production rollbacks. Say I'm working on one feature in one branch and I've split a column, then I need to work on a hotfix on another branch which doesn't have that split column. It's really useful being able to switch to that branch and quickly get my database rolled back into a state to match