Where is the “Danger Zone” for projects written in Motoko and deployed on the IC

I recently deployed an app on the IC. I’m still in the testing phase, but I’m curious as to which files are critical for preserving canister data. .dfx, dist, and the node_modules Directory all seem like really important files. Is it the case that if these files are alter/deleted, that it’ll result in loss of data? Or can these files be simply recovered using npm install and dfx deploy and everything’s all good?

Essentially, i wanna know where i need to be extra careful in order to prevent data loss?

1 Like

I think the actual replica state and canister memory cannot be recovered from the .dfx directory, if you deploy to mainnet.

I believe some folks on DFINITY like @akhilesh.singhania are working on a way for canister owners to download (and upload) the entire canister memory/state directly from mainnet.

2 Likes

None of that is essential. Dfx Build will restore dist, and .dfx and nom install will restore node_moduals.

The thing that will lose you data is changing data structures in your .no files. Some Kind of primer on what makes a braking change would be useful.

2 Likes

How would I go about making updates to data structures in my .mo files? is the only option for updating data structures to make an entirely new object type?

I’ve considered doing (bad code written on phone)

my_type ={#first; #second;};
my_type_v2 = {#first; #third};

func modifyfunc(anItem :my_type) : my_type_v2{
     Switch(anItem){
     //convert it

     }
};

post_upgrade(){
      for(thisitem in my_type_collection.vals()){
            my_type_v2_collection.add(modifyfunc(thisItem))
      }

};
1 Like