Skip to content
Playground(another site)

bynk.parse.migrate_after_handler

Error A migrate step is declared after an agent handler; migration steps precede the handlers.

A migrate step carries a stored record from an older schema version to the agent's current shape, so it belongs with the agent's storage and invariants, above the handlers that read the migrated state. One written after a handler is refused. Move it above the first handler. bynk.parse.invariant_after_handler and bynk.parse.transition_after_handler are the same rule for invariants and transitions.

Example

type CartV1 = { owner: String, total: Int }
agent Cart {
key id: String
store ownerName: Cell[String]
store totalCents: Cell[Int]
on call cents() -> Effect[Int] { … }
migrate from 1 (old: CartV1) { // ✗ after a handler
ownerName := old.owner
totalCents := old.total * 100
}
}
agent Cart {
key id: String
store ownerName: Cell[String]
store totalCents: Cell[Int]
migrate from 1 (old: CartV1) { // ✓ before the handlers
ownerName := old.owner
totalCents := old.total * 100
}
on call cents() -> Effect[Int] { … }
}

In the Book

See also

  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.migrate_after_handler shows the same from the installed toolchain, without a network.