What problem does it solve?
This Skill solves the problem of upgrading an Internet Computer canister written in Motoko without losing or corrupting actor state when the actor’s fields or types change.
Core Features & Use Cases
- Inline actor migration: Attach a
(with migration = ...) expression to an actor to define how old state transforms into new state during upgrades.
- Implicit compatibility migration: Rely on runtime compatibility for safe changes like adding/removing fields, changing mutability, and widening types.
- Explicit migration rules: Use a migration function with persistable, non-generic record input/output types, with clear guidance for renames, type changes, restructuring, and collection/value transformations.
Quick Start
Use (with migration = Migration.run) immediately before your actor definition, and implement run(old : { ... }) : { ... } to convert your previous record shape into the new record shape for the fields that changed.