Skip to content

fix(deploy): match D1 migrations_dir by folder, not by text - #502

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/d1-migrations-dir-compare
Oct 20, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/d1-migrations-dir-compare

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Fixes #499

Problem

user writes   migrations_dir: "db/migrations"
Void wants    "./db/migrations"

preflight     "db/migrations" !== "./db/migrations"  → differs → provision
provisioner   same folder → keeps the user's spelling → writes nothing
preflight     still !== → exit 1 "provisioning did not set migrations_dir... Retry"
next run      same state → same failure

The two checks treated the value differently: the preflight compared the raw text, while the provisioner compared normalized paths. Existing tests missed it because the only db/migrations test reuses an existing Worker, and that path skips the check.

Fix

A new helper, sameMigrationsDir(configPath, a, b) in wrangler.ts, says whether two values point to the same folder. It turns \ into / and resolves both values against the config's folder, the way Wrangler does. The preflight and the provisioner both use it, and the user's spelling is kept as written.

migrations_dir Before Now
./db/migrations ✓ ✓
db/migrations, db/migrations/, ./db/migrations/, src/db/migrations (sourceDir src) ✗ fails on every deploy ✓
absolute <root>/db/migrations ✗ "different directory" error ✓
not set Void fills it in same
another folder (drizzle) error only after provisioning stops before any account call, with a clear message

Void generates and applies migrations only from <sourceDir>/db/migrations, so it can't use another folder. The new error names that folder and the file to edit:

deploy: D1 binding "DB" sets migrations_dir "drizzle", but Void generates and applies migrations from "./db/migrations". Set migrations_dir to "./db/migrations" in cloudflare.d1_databases of void.config.ts, or remove it and Void will fill it in.

The "or remove it" part is shown only when the value is in void.config.ts. It is left out when Void filled the value in and stored it in void.lock.json.

Not in this PR: a backslash spelling (db\migrations) now passes the preflight. On macOS and Linux it still fails in a later step, the migration apply-set check, which void db migrate --remote also uses. That is a separate bug.

Tests

  • cloudflare-deploy.test.ts:
    • same-folder spellings deploy without provisioning;
    • another folder stops before any account call, for wrangler.jsonc, for void.config.ts, and with sourceDir set;
    • no "remove it" hint when the value comes only from void.lock.json;
    • the issue's void.config.ts setup: the first deploy provisions through the real config writer, and the second deploys with no provisioning.
  • wrangler.test.ts: an absolute path to the right folder is kept as written.

All 12 new tests fail on main. The 6 test files that mention migrations_dir pass (876 tests). Lint, format and typecheck are clean.

🤖 Generated with Claude Code

A migrations_dir such as "db/migrations" names the same folder as the
"./db/migrations" Void expects, but the preflight compared the raw text.
The provisioner kept the equal spelling, so every Cloudflare deploy
stopped with "provisioning did not set migrations_dir". Both checks now
resolve the value against the config folder, which also accepts an
absolute path. A migrations_dir for another folder stops the deploy
before any account call, with a message that names the expected folder
and the file to edit.

Fixes #499

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T08:34:45.677971Z 1956714 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 536b04fe04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/void/src/cli/deploy-cloudflare-preflight.ts
With an absolute migrations_dir that names Void's folder, the pattern
check still used "./db/migrations", so a pattern with the same absolute
prefix was rejected. Wrangler checks the pattern against the configured
spelling; do the same.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1956714a75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-d1-migrations-dir-compare-void-cloud.voidzero-docs.workers.dev (commit 1956714)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ee68f401-void-cloud.voidzero-docs.workers.dev 1956714 2026-10-20T08:33:46.423Z Visit the dashboard ↗

@Brooooooklyn
Brooooooklyn merged commit f53f2b7 into main Oct 20, 2026
20 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/d1-migrations-dir-compare branch October 20, 2026 08:51
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.

deploy: migrations_dir "db/migrations" never matches the expected "./db/migrations", so Cloudflare deploy always stops

1 participant