Skip to content

Managed MySQL deploys send a migration without breakpoints as one multi-statement query, which Hyperdrive does not support #414

Closed

Description

@Brooooooklyn

Problem

A MySQL app deploys to the Void platform with void deploy. The platform applies pending migrations through the app Worker's migration handler. That handler reaches MySQL through Hyperdrive.

A migration file can have several statements and no --> statement-breakpoint lines. A hand-written file is the usual case; void db generate adds the lines. The handler sends such a file as one query, on a connection opened with multipleStatements: true.

Cloudflare's Hyperdrive docs list "Multi-statement queries" as an unsupported MySQL feature. So this file will probably fail on a real Hyperdrive, and the deploy stops. We have not run this against a real Hyperdrive. Miniflare's local Hyperdrive is a plain TCP proxy, so local runs pass.

Path Connects through File with several statements and no breakpoints
void db migrate, void deploy --platform cloudflare DATABASE_URL, direct sent as one query; MySQL accepts it
void deploy (Void platform) Hyperdrive sent as one query; unsupported per Cloudflare docs

Two related gaps for the same files:

  1. No partial-apply note. When a file fails partway, void db migrate adds a note: "MySQL commits schema changes immediately, so earlier statements in <file> may already be applied...". The note shows only when at least one statement finished. A file without breakpoints is one query, so the count stays 0 and the note never shows, even when its first CREATE TABLE was committed. On MySQL 8.4:

    ■ migration 0002_comments.sql failed: Key column 'nope' doesn't exist in table
    

    The table comments now exists, but the file is not recorded. The next run fails with Table 'comments' already exists. The same SQL with a breakpoint line shows the note.

  2. Sharded Vitess. Each file runs between BEGIN and COMMIT. On a sharded Vitess keyspace (for example PlanetScale MySQL), the default transaction mode is MULTI. A commit that fails on one shard does not roll back the shards that already committed (Vitess docs, shard isolation and atomicity). So a data-only file that writes to several shards can partly apply. docs/guide/database/mysql.md:58 says "a failed file that only changes data leaves the database unchanged". Not run on a sharded keyspace.

Repro

Hyperdrive (not confirmed live):

  1. In a MySQL app, add db/migrations/0002_two.sql (and its journal entry) with no breakpoint line:
    CREATE TABLE comments (id int primary key);
    CREATE TABLE tags (id int primary key);
  2. Run void deploy to the Void platform.
  3. Per Cloudflare's docs, Hyperdrive rejects the multi-statement query and the migration fails.

Missing note (seen on MySQL 8.4):

  1. Add 0002_comments.sql with no breakpoint line:
    CREATE TABLE comments (id int primary key);
    ALTER TABLE counters ADD CONSTRAINT bad FOREIGN KEY (nope) REFERENCES comments(id);
  2. Run void db migrate. The error has no note, and comments exists.
  3. Run it again: Table 'comments' already exists.

Cause

  • packages/void/src/runtime/migration-handler-mysql.ts:53-57 opens the Hyperdrive connection with multipleStatements: true; :88-91 sends each piece from splitMigrationSql. On main: :51-54 and :71-73.
  • packages/void/src/runtime/migration-handler.ts:714-720: splitMigrationSql returns the whole file as one piece when it has no breakpoint line.
  • packages/void/src/migrations/runner-mysql.ts:148-167: ran counts finished queries, and the note needs ran > 0 (:163-164, message at :115-126).

Suggested fix

  • For MySQL, reject a file with several statements and no breakpoint lines when Void plans migrations, with a clear message ("add --> statement-breakpoint after each statement"). Then drop multipleStatements from the Hyperdrive connection. A SQL-aware splitter is the other option, but it must respect strings, comments and BEGIN ... END bodies.
  • Show the note for a failed file without breakpoints when the file has more than one statement and the transaction is no longer open.
  • Docs: say that on sharded Vitess a file that writes to several shards is not atomic.
  • Check the behavior once against a real Hyperdrive.

Evidence

🤖 Generated with Claude Code

https://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH

Activity

  1. added 2 commits that reference this issue on Oct 14, 2026
    8d66ca9
    84c8140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions