Questions about data structures and migrations

I should add that we intend to eventually supply a tool that will check whether the types of stable variables are compatible across two versions of code. This essentially boils down to checking that the record of stable variables (identified by name) either introduces new fields or evolves existing fields to supertypes. Your original code fails that second requirement, because

[(Nat32,{ title : Text})] is not a subtype of [(Nat32, { title : Text; description: Text}]

but we don’t check that for you yet.

You need to be able to initialize a stable variable from its previous value or initializer, so the “old” type must be a subtype of the “new” type.

2 Likes