migrating-motoko-enhanced
Installation
SKILL.md
Enhanced Multi-Migration
Manage canister state evolution through a chain of migration modules. Each migration captures one logical change (add, rename, drop, transform a field) and the compiler verifies the entire chain is consistent.
When to Use
- Adding, removing, or renaming persistent actor fields
- Changing a field's type
- Restructuring state across canister upgrades
- Project has
[canisters.<name>.migrations]configured inmops.toml
Critical Rules
- Never use
stablekeyword,preupgrade/postupgrade, or inline(with migration = ...) - Actor variables are declared without initializers — values come from the migration chain
- The actor body must be static (no top-level side effects except
<system>calls like timers) - Each migration file exports
public func migration({...}) : {...} - Files are applied in lexicographic order — use timestamp prefixes