Hi @Claudio ,
step1.mo
import TrieMap "mo:base/TrieMap";
import Iter "mo:base/Iter";
import Nat32 "mo:base/Nat32";
import Debug "mo:base/Debug";
shared ({caller = initPrincipal}) actor class Example () {
public type State = {
db: TrieMap.TrieMap<Nat32, Card>;
};
func empty () : State {
{
This file has been truncated. show original
step1.txt
[Canister qoctq-giaaa-aaaaa-aaaea-cai] Begin preupgrade
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 0
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 1
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 3
[Canister qoctq-giaaa-aaaaa-aaaea-cai] End preupgrade
[Canister qoctq-giaaa-aaaaa-aaaea-cai] Begin postupgrade
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 0
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 1
[Canister qoctq-giaaa-aaaaa-aaaea-cai] cardId : 3
[Canister qoctq-giaaa-aaaaa-aaaea-cai] End postupgrade
step2.mo
import TrieMap "mo:base/TrieMap";
import Iter "mo:base/Iter";
import Nat32 "mo:base/Nat32";
import Debug "mo:base/Debug";
shared ({caller = initPrincipal}) actor class Example () {
public type State = {
db: TrieMap.TrieMap<Nat32, Card>;
};
func empty () : State {
{
This file has been truncated. show original
There are more than three files. show original
Here is a gist showcasing my problem. In the second step I just add a “description” field in the card type.
I lose the state without warning.
So I have two problem, how to upgrade and how to be notified if I fail to migrate my data.
Hope this helps.
1 Like