fetches one chunk by file name and index
fetches the manifest (memoised by getManifest())
Optionalmanifestthe manifest once loaded
the clock, injectable for tests
the tenant database the chunks replay into
the storage handle whose transactionSync() makes a chunk atomic with its cursor
the manifest, loaded once per migrator
Clears the cursor and every table the manifest declares so a re-migration starts empty. Destructive; the route gates it behind an explicit flag.
runs to completion: the paid and local shape (on free it exceeds the ceiling)
everything a diagnostics route needs about the migration, in one read
Replays up to maxChunks chunks (default one; Infinity is the paid and local path), then
returns. A chunk that throws leaves the database as it was and records the error without
advancing the cursor, so the next call retries it; skipping would leave a site quietly
missing rows.
First-run migration, replayed in JavaScript into
ctx.storage.sql. A JS loop is divisible where a synchronous wasm call is not: one chunk per invocation, cursor in DO SQLite, resume next time.The cursor advances inside the same
transactionSync()as the chunk's statements, so a killed invocation retries from a consistent point (actx.storage.put()cursor would be a second commit).loadManifest,loadChunkandnoware injected so gate tests replay off disk.