Is there anyway to have preconditions for my rollback tag. I have this scenario:
Changeset renames table from users to users_to_delete
A different changeset with a different context (CLEANUP) will be dropping table named users_to_delete
So, the rollback to my first changeset would be to rename table users_to_delete to users.
But, if the CLEANUP was run, then my table would already be gone.
I’d like to have a precondition tableExists on the rollback, but… keep getting errors.
Any help would be appreciated.
Currently you cannot specify a precondition tag in rollback. The idea is to have rollback very straightforward and non-complex so you know exactly what is going to happen.
I see your problem, though. I think the easist approach would be to add something like the onError flag to the rollback tag. I created https://liquibase.jira.com/browse/CORE-2702 to track the feature.
Do you have many cases where you run into this? If there are just a few, and depending on your database you could change the rollback to use straight sql and use a “drop if exists” syntax.
Nathan