Skip to content

fix(d1): allow remote d1 migrations when id is not specified#12810

Open
Lp-Francois wants to merge 2 commits intocloudflare:mainfrom
Lp-Francois:fix-for-d1-remote-migration-allow-running-migrations-on-d1-without-an-id
Open

fix(d1): allow remote d1 migrations when id is not specified#12810
Lp-Francois wants to merge 2 commits intocloudflare:mainfrom
Lp-Francois:fix-for-d1-remote-migration-allow-running-migrations-on-d1-without-an-id

Conversation

@Lp-Francois
Copy link

@Lp-Francois Lp-Francois commented Mar 8, 2026

Fixes #12809

Describe your change...

allow remote d1 migrations when id is not specified.

Perform a look up when ID is missing to allow running migrations when the DB is auto-provisioned from the wrangler file.

See the issue for more context (I couldn't run the remote migration if the ID is not specified in the wrangler.jsonc file.)

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: it's a bug

A picture of a cute animal (not mandatory, but encouraged)

random cat pic from google :D
Open with Devin

perform a look up when ID is missing to allow running migrations when the DB is auto-generated from the wrangler file

issue cloudflare#12809
@Lp-Francois Lp-Francois requested review from a team as code owners March 8, 2026 19:22
@changeset-bot
Copy link

changeset-bot bot commented Mar 8, 2026

🦋 Changeset detected

Latest commit: 99e85d6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod
Copy link
Contributor

Codeowners approval required for this PR:

  • @cloudflare/d1
  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/d1/migrate.test.ts: [@cloudflare/d1 @cloudflare/wrangler]
  • packages/wrangler/src/tests/d1/utils.test.ts: [@cloudflare/d1 @cloudflare/wrangler]
  • packages/wrangler/src/d1/migrations/apply.ts: [@cloudflare/d1 @cloudflare/wrangler]
  • packages/wrangler/src/d1/migrations/list.ts: [@cloudflare/d1 @cloudflare/wrangler]
  • packages/wrangler/src/d1/utils.ts: [@cloudflare/d1 @cloudflare/wrangler]

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

});
if (
dbFromConfig?.uuid !== undefined &&
dbFromConfig.uuid !== dbFromConfig.binding
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused by this. Why are we testing for .uuid != .binding?

Oh: getDatabaseInfoFromConfig() does some nonsense where it returns the db binding.

This is going to be fragile when we implement #11870. Can we parse the uuid to validate that it is a uuid instead?

@alsuren
Copy link
Contributor

alsuren commented Mar 9, 2026

I agree with this change in general (as long as there are no objections from the wrangler team). One tiny comment an then let's get it in.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 9, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12810

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12810

miniflare

npm i https://pkg.pr.new/miniflare@12810

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12810

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12810

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12810

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12810

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12810

wrangler

npm i https://pkg.pr.new/wrangler@12810

commit: 047b79f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

[BUG] When D1 ID is not specified, wrangler fails to run the migration

3 participants