You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Borsh does not include the schema inside the serialized data, so you should plan your upgradability accordingly. If you start from scratch, you have two paths:
keep versioned data structured using enum (enum MyStruct { V1(MyStructV1) }), which will add a one byte tag as part of the borsh serialization for enums, here is an example
plan to keep the data always at the latest state and as such, implement migration logic that would read all the old data using old structs, convert those into the new structs, and write it over using, here is an example
If you already have the data serialized with the old MyStruct, you can follow (2) and consider to implement (1) for seamless operation going forward.
Would you like to contribute a README/docs for this topic? I would be happy to review a PR
Hi there,
We have some existing serialized data of something like
We would now like to add a new field to the existing struct to have something like:
However, when deserializing existing data with the new
MyStruct
, the following error is returned:What is the recommended way to add fields to an existing struct, that already has serialized data?
The text was updated successfully, but these errors were encountered: