I have a moderately sized application that uses Data.Acid for persistence and I've encountered a situation where I need to update the implementation of one of my Update events for the next version of the server. I.e. I have something like
myUpdate :: Update MyState ()
myUpdate = <some outdated implementation>
Now, obviously I can't just change the implementation haphazardly as it would corrupt my transaction history, so I was wondering how people usually handle this. The way I see it my options are:
Stop the server. Run
createCheckpointfor myAcidState. Update theEventimplementation and then restart the server. Since we load from a fresh snapshot, the changedUpdateshould never trigger for the old events.Create a a new
Updatewith a new name (likemyUpdate_v2) and update my server logic to only usemyUpdate_v2everywhere instead of the originalmyUpdate.
I think both options have their merits. (1) is nicer since I don't need to retain the old functionality in my codebase but it has to be done very carefully for each server I update or I risk corrupting data. (2) is safer (especially if I remove the old myUpdate from my module's exports so I can be sure I don't accidentally use the old implementation anywhere), but it feels a bit ugly otherwise.
Is there some better way of doing this? I see this as something I will definitely encounter every then and again in a long-lived project so I would like to have a good, standard workflow for applying changes to the implementation of my events.