P02
Warning
What is kept in the browser
P02 — A migration that never runs
A migrate step above the declared version:.
What the compiler said
warning[P02]: `migrate 1 -> 2` on `items` is past the declared version --> src/App.wf:2:5 | 2 | persist items: [String] = [] { | ^^^^^^^ = help: A step above `version:` never runs; raise the version or drop the step = docs: https://webfluent.monzeromer.dev/errors/P02
The fix
Broken
store Cart {
persist items: [String] = [] {
version: 1
migrate 1 -> 2 { old }
}
}
Fixed
store Cart {
persist items: [String] = [] {
version: 2
migrate 1 -> 2 { old }
}
}
page P(path: "/", title: "T", description: "D") {
use Cart
Heading("{Cart.items.length} items").h1
}
Raise version: to the step's target, or drop the step.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
lints may lower it:
"lints": { "P02": "off" }
// wf-allow(P02)