drupflare/worker - v1.0.0
    Preparing search index...

    Class SqlMigrator

    Drives the chunk replay.

    loadManifest / loadChunk are injected rather than reading env.ASSETS directly so the gate tests can replay the real shipped chunks off disk into a real SQLite without a dev server. now is injected for the same reason.

    Index
    loadChunk: (file: string, index: number) => Promise<MigrationChunk>
    loadManifest: () => Promise<MigrationManifest>
    manifest: MigrationManifest | null
    now: () => number
    sql: SqlLike
    storage: StorageLike
    • Clears the cursor AND every table the manifest declares, so a re-migration starts from empty rather than colliding with its own previous rows.

      Destructive by definition, which is why the route gates it behind an explicit flag.

      Returns Promise<MigrateResetResult>

    • Everything a diagnostics route needs about the migration, in one read.

      The JSDoc @returns that used to sit here was WRONG -- it claimed {state, chunk, chunks, done} while the method returns generation, chunks, statements, rows, cursor, done and started. It went unnoticed because JSDoc types on a .js file are advisory; once the file became TypeScript the declared MigrateStatus contradicted it in plain sight, which is the argument for the conversion in one line.

      Returns Promise<MigrateStatus>

    • Replays up to maxChunks chunks, then returns.

      One chunk is the default because one chunk is the unit sized to fit a single invocation's CPU budget. maxChunks: Infinity is the paid-plan and local path, where the whole migration in one invocation is simply cheaper.

      A chunk that throws leaves the database exactly as it was and records the error on the cursor without advancing it, so the next call retries the same chunk rather than skipping it. Skipping a failed chunk is how you get a site that renders and is quietly missing rows.

      Parameters

      Returns Promise<MigrateStepResult>