Skip to content

Release 1.2.7: migrate:worker through the D1 HTTP API - #71

Merged
jurczykpawel merged 5 commits into
mainfrom
fix/migrate-fast
Nov 28, 2026
Merged

jurczykpawel merged 5 commits into
mainfrom
fix/migrate-fast

Conversation

@jurczykpawel

Copy link
Copy Markdown
Owner

npm run migrate:worker (the schema step of npm run release) started npx wrangler d1 execute DB --remote --command for every query (~46 queries even with nothing to do). It now sends the same SQL text to the endpoint wrangler uses for --command (POST /accounts/<account>/d1/database/<MAILSTACK_D1_ID>/query {sql}), with wrangler's credentials from one wrangler auth token --json call.

  • Same queries, same order, same multi-statement atomic batches, same abort on any failed request (remoteStore, migrateWorker, release manifest checks unchanged).
  • Account: CLOUDFLARE_ACCOUNT_ID, otherwise the only account of the credentials; several accounts -> clear error.
  • Measured on Cloudflare D1 (staging account): no pending migrations 42.7–49.4 s -> 4.1–5.6 s; fresh database 63.7 s (119.9 s at load 234) -> 6.4–7.2 s. Old and new code produce identical sqlite_master and Pro ext_migrations on fresh databases.
  • Tests: transport request shape, refused/partial responses, a refused request in the middle stops the migration, account selection.

🤖 Generated with Claude Code

@jurczykpawel jurczykpawel changed the title migrate:worker: D1 HTTP API instead of a wrangler process per query Release 1.2.7: migrate:worker through the D1 HTTP API Nov 28, 2026
@jurczykpawel
jurczykpawel merged commit 2b3f334 into main Nov 28, 2026
11 checks passed
@jurczykpawel
jurczykpawel deleted the fix/migrate-fast branch November 28, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant