Command Palette

Search for a command to run...

Назад к скиллам
скилл № 02927

troubleshooting-motoko-migrations

Deep reference for when the Motoko migration chain misbehaves — upgrade compatibility errors you cannot explain, migration files you cannot write, a first…

БесплатноБез исполняемых скриптов
jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Установить troubleshooting-motoko-migrations в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Troubleshooting Motoko Migrations

Reference for the failure modes of the mops-managed migration chain (migrations/).

Do not load this for routine work. Writing a migration, deciding implicit vs explicit, or naming a new file is covered by migrating-motoko-actors — that skill's rules are sufficient for the normal path. Come here when:

  • a compatibility or migration diagnostic does not match what you see in main.mo
  • a write to a migration file fails, or you are tempted to rename/delete one
  • the first file in the chain has a non-empty OldActor and you are unsure whether that is a bug
  • the task asks you to remove migrations, restore inline initializers, or go back to (with migration = ...)
  • mops check complains about a state shape that is not in the current source

How the runtime decides what to run

  • The whole chain is compiled into the backend wasm. There are no separate migration artifacts — changing any migration file changes the wasm.
  • Applied migrations are tracked by module name (the filename without .mo) in the canister's persistent metadata.
  • On upgrade, the runtime replays only the migrations that module name says have not been applied yet. Deploying onto a canister several versions behind replays all the missing steps in one upgrade — you never need intermediate deploys to "catch up".
  • On fresh install, every file in the chain replays in lexicographic order. Every migration ever added runs on every fresh install of the project, forever.

Two consequences drive most of the rules in this skill:

  • Renaming a migration changes its identity. The runtime would treat the renamed file as never applied and replay it against state that no longer matches — or skip the work the old name recorded. Filenames are permanent.
  • Editing an applied migration is invisible to a canister that already ran it. The runtime skips it by name, so an edited body never executes. A stable field you add there is never initialized, and the canister traps at runtime reaching for it (IC0503, "missing migration var" class). Fix forward with a new migration instead.

What the checker compares against

mops check validates your chain against the deployed canister's stable signature (its .most snapshot), not against local git history. So:

  • Diagnostics can name fields that are no longer anywhere in your source — they come from the deployed version.
  • The one-pending-migration limit counts migrations newer than that baseline. Files the baseline already records do not count toward it.
  • The stable-signature major in a .most header identifies the persistence model: 1 classic, 3 legacy inline (with migration = ...), 4 enhanced migration chain. Once a project reaches 4 it never goes back (see EM is one-way).

Diagnostics you may hit

Diagnostic What it actually means Action
M0250 initialized stable field A stable actor field has an inline initializer, which the chain (not the actor body) must supply Reduce it to a typed declaration; move the initializer expression into the pending migration's NewActor
M0254 / M0267 initial actor requires field main.mo declares a stable field that no migration supplies. M0267 is the same problem when the deployed signature cannot account for it either Add the field to the pending migration's NewActor with a value computed from OldActor or a well-defined default
M0170 compatibility error The new actor is not stable-compatible with the deployed signature Add (or extend) the pending migration so the transformation is explicit
M0255 stable signature downgrade The build would move the canister from an enhanced chain back to an older persistence model — usually because the chain or the mops migrations config was removed Restore what was removed; there is no supported downgrade
Chain start does not match the baseline The first migration's OldActor does not describe the state the canister actually holds — the classic case is a converted project where the chain starts from the legacy shape, not {} See Converted projects; do not rewrite OldActor to `{}
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • LICENSE
  • SOURCE.md
  • TRUST.auto.yaml

FAQ

Что делает скилл troubleshooting-motoko-migrations?

Deep reference for when the Motoko migration chain misbehaves — upgrade compatibility errors you cannot explain, migration files you cannot write, a first migration whose OldActor is non-empty, a project converted from legacy persistence, or a request to delete/remove the migrations directory or revert to inline (with migration = ...). Load only when the rules in migrating-motoko-actors do not explain what you are seeing.

Как установить скилл troubleshooting-motoko-migrations?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл troubleshooting-motoko-migrations запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить troubleshooting-motoko-migrations с