I want to add a bunch new optional properties/members to types - will I lose my data? DSocial

This post proposes one solution. Not super elegant but safe.

The idea is to define a new stable variable with the richer type and initialize it from the old one, inserting appropriate values for new fields.

The second link above on Compatibility has a similar example at the very end.

If you don’t like having to come up with new names, you can define your state variable as a variant type and add a new variant whenever you need to change the type. The Life example on the GH dfinity/examples repo does something like that.

2 Likes