Skip to content

fix(d1): reject migration names that Windows cannot store - #411

Merged
petebacondarwin merged 1 commit into
cloudflare:mainfrom
Cherry:fix/d1-migration-name-reserved-chars
Oct 26, 2026
Merged

petebacondarwin merged 1 commit into
cloudflare:mainfrom
Cherry:fix/d1-migration-name-reserved-chars

Conversation

@Cherry

@Cherry Cherry commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #410

cf d1 migrations create now rejects names containing : * ? " < > |, the same way it already rejects / and \.

On Windows, a : in the name made NTFS write the SQL into an alternate data stream of an empty file (0001_users instead of 0001_users:_add_email.sql). The command reported success, apply never picked the file up, and the next migration reused the same number. The other characters failed with a raw ENOENT.

The check runs on every platform, since migrations are committed and a name that works on Linux or macOS would still break a Windows checkout.

  • Added a test per character in create.test.ts
  • Added a patch changeset

A `:` in the name made NTFS write the SQL into an alternate data stream,
so the migration was silently skipped. The other reserved characters
failed with a raw ENOENT.

Fixes cloudflare#410
@github-actions

Copy link
Copy Markdown
Contributor

Hi @Cherry. Thanks for contributing to cf!

During the open beta, we’re being very intentional about the changes we accept so that we can prioritise stability for GA. We’re limiting pull requests to contributions coordinated with the team in advance, so this PR has been automatically closed.

We’d still love to hear about your use case, so please make sure it’s captured in a cf issue. If the proposed change fits our priorities, we’d be happy to take another look at this PR.

@clanky-the-clanker

clanky-the-clanker Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

✅ Approved — This is a small, well-tested fix that rejects Windows-reserved characters before anything is written to disk, and no issues were found in the code, tests or changeset.

The decision is advisory: this comment never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

The new reserved-character check in packages/cli/src/commands/d1/migrations/create.ts matches the existing path-separator check. It runs before the --pattern check, the directory creation and the file write, so a rejected name leaves nothing on disk. create.test.ts checks this for each character by asserting that migrations does not exist. The check applies on every platform, which suits migration files that are committed and shared across operating systems.


📝 Documentation: ✅ LGTM

The changeset follows the repository's format: "cf": patch frontmatter, an imperative title and a short body that explains the NTFS alternate-data-stream behaviour. The code comment explains why the check exists.


Reviewed commit: 4999d2da

@petebacondarwin

Copy link
Copy Markdown
Collaborator

clanker review

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@411

commit: 4999d2d

@petebacondarwin
petebacondarwin removed the request for review from edmundhung October 26, 2026 11:58
@petebacondarwin
petebacondarwin added this pull request to the merge queue Oct 26, 2026
Merged via the queue into cloudflare:main with commit b31a9ea Oct 26, 2026
9 checks passed
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.

cf d1 migrations create hides the migration on Windows when the name contains :

2 participants