Trying to publish a new version of my map. There are no backwards compatibility errors when building Verse, when launching a session, pushing changes or verse changes, pushing a private version, or at any other time.
However, when I try to publish, there’s a red X next to my private version on the publish screen and this message on hover:
You can’t publish this version because your Verse persistable data is not backward compatible with your current active version. Please publish a new version from UEFN that is compatible with your current active version.
I haven’t changed my save data format or functionality; I haven’t made any updates to the verse file that it’s in. There should be no issue with backwards compatibility (and as I said, no other errors at any other time).
The only thing I can think of is that one of the variables in my save data (which is itself a class, as is recommended in the persistence documentation) is a map of type [enum]float, and I have updated the enum entries (I’ve only added enum entries, not removed). The enum is (and has been) set as persistable since the first implementation of the save data.
If that’s the issue, how do I make that backwards compatible and fix this issue?
So it appears that changing an enum that’s used as a Key in a map leads to the backwards compat issue.
So the issue then becomes: how do I create a new version of this save data variable?
I can’t update the enum, or else that breaks it. I can’t create a new enum for my code as it breaks a bunch of other of my map implementation. I can’t create a new save variable that doesn’t use the enum as a key, because the old one still has to be there. I can’t rollback to a previous publish version, because the first published version contains this same save data.
A common way would be to make migration scripts, add a new field, read the current player data version and migrate accordingly, I believe they talk about it a bit in their article
So my solution was to duplicate the map and instead of using the enum as the map key, convert the enum to string and use a string as a key instead going forward. I suppose you could possibly deprecate your enum and create a new enum and convert that to string without duplicating the map, but depending on your verse infrastructure, it may not be a great solution.