Open samlinux opened 7 months ago
One way is to add new properties as optional
type License = {
license: Text;
active: Bool;
status: ?Bool; // optional
};
This can be suboptimal as it will make you handle optional types explicitly every time you try to access licence.status
That's why I've designed a migration pattern some time ago (similar to what you could use while working with SQL databases)
Here is a sample project structure that can help you implement this migration pattern in your project
Thank you I will study it.
Hey 👋 , the migration strategy works in my example, thanks for putting it together.
I have structure like this:
type License = { license : Text; active : Bool; }; stable let map = Map.new<Nat, License>();
After some time I would like to add a further property to the License type: e.g. status:
type License = { license : Text; active : Bool; status:Bool; };
During the update process I receive a warning, what is fine.
But, If I install the update, my data is lost and the query call failed.
So how can I handle this situation ?