I also feel like a version-to-version upgrader would be better if possible. That's how we've managed upgrades for save games in the past. The solution there has simply been to have the old class around with all of it's data, and do the steps one-by-one.



It's inconvenient, sure. But writing the upgrader is a LOT easier when you go version to version. With the upgrader-runs-once scheme, introducing version n requires updating the code to support n-1 version of the data - so there's n-1 new places where bugs can live. With the version-to-version scheme, you only have to create a single new upgrade path. That's a lot more manageable.





No matter what solution is picked, the upgrader crashing will always be a problem. You can't get around it. This is another point in favor of having an upgrade-everything option; if we can do a commit, and then run all of the upgrades at once, a failed upgrade can be fixed by simply reverting to an earlier stage. If the upgrader runs as we go, a rare failure will be very hard to pick up on, and might suddenly appear next to a bunch of data we want to keep, making the revert difficult.

Click to expand...