Four zero-dependency safety checks to run before wrangler d1 migrations apply — ordering, config validation, destructive-SQL scanning, and trigger-safety. Free, MIT-licensed, local-only.
0
stars
5
commits
HTML
primary language
Sep 8, 2026
updated
mattbridges.github.io/d1-migration-guard
Three zero-dependency safety checks to run before wrangler d1 migrations apply. Free, MIT-licensed, reads local files only — never calls wrangler
and never touches a live database.
src/ordering.js) — sorts migration filenames explicitly
and flags anything that would differ under raw filesystem order, plus
duplicate or gapped numeric prefixes. This is the exact bug class fixed
upstream in
cloudflare/workers-sdk#13568.src/config.js) — parses wrangler.toml's
[[d1_databases]] blocks (a narrow hand-rolled parser, not a general TOML
library, to stay zero-dependency) and flags a missing or placeholder
database_id — the failure mode behind
workers-sdk#5049.src/destructive-sql.js) — regex-based flags
for DROP TABLE, ALTER TABLE ... DROP COLUMN, unsafe renames,
unfiltered DELETE FROM, and DROP INDEX. Deliberately a fast pattern
scan, not a real SQL parser: false positives are fine (a human reviews
the flag), false negatives on obfuscated SQL are a known, documented
limitation of this v0.1 free tier.Not yet published to npm (see Status below), so for now, clone and run directly:
git clone https://github.com/MattBridges/d1-migration-guard.git
cd d1-migration-guard
node bin/d1-migration-guard.js check --migrations-dir /path/to/migrations --config /path/to/wrangler.toml
Requires Node.js >= 18. Zero npm dependencies.
Exit code 2 on any high-severity finding, 0 otherwise (including "minor
issues found" — a human still reads the output either way).
Executed (not just self-reviewed) via node:20 against two fixture sets — a
clean migration set (all three checks pass, exit 0) and a deliberately bad
one (duplicate/gapped ordering, a placeholder database_id, and
DROP TABLE/DROP COLUMN/unfiltered DELETE in one file). All three
checks correctly detected every planted issue with the expected exit code
(2). Source-only release for now — not yet published to the npm registry
(the npx d1-migration-guard form in earlier drafts of this README doesn't
work until that happens).
wrangler d1 execute --local) — gated on this free CLI validating demand first.MIT
5 commits
HTML
52.3%
JavaScript
47.7%
Four zero-dependency safety checks to run before wrangler d1 migrations apply — ordering, config validation, destructive-SQL scanning, and trigger-safety. Free, MIT-licensed, local-only.
0
stars
5
commits
HTML
primary language
Sep 8, 2026
updated
mattbridges.github.io/d1-migration-guard
Three zero-dependency safety checks to run before wrangler d1 migrations apply. Free, MIT-licensed, reads local files only — never calls wrangler
and never touches a live database.
src/ordering.js) — sorts migration filenames explicitly
and flags anything that would differ under raw filesystem order, plus
duplicate or gapped numeric prefixes. This is the exact bug class fixed
upstream in
cloudflare/workers-sdk#13568.src/config.js) — parses wrangler.toml's
[[d1_databases]] blocks (a narrow hand-rolled parser, not a general TOML
library, to stay zero-dependency) and flags a missing or placeholder
database_id — the failure mode behind
workers-sdk#5049.src/destructive-sql.js) — regex-based flags
for DROP TABLE, ALTER TABLE ... DROP COLUMN, unsafe renames,
unfiltered DELETE FROM, and DROP INDEX. Deliberately a fast pattern
scan, not a real SQL parser: false positives are fine (a human reviews
the flag), false negatives on obfuscated SQL are a known, documented
limitation of this v0.1 free tier.Not yet published to npm (see Status below), so for now, clone and run directly:
git clone https://github.com/MattBridges/d1-migration-guard.git
cd d1-migration-guard
node bin/d1-migration-guard.js check --migrations-dir /path/to/migrations --config /path/to/wrangler.toml
Requires Node.js >= 18. Zero npm dependencies.
Exit code 2 on any high-severity finding, 0 otherwise (including "minor
issues found" — a human still reads the output either way).
Executed (not just self-reviewed) via node:20 against two fixture sets — a
clean migration set (all three checks pass, exit 0) and a deliberately bad
one (duplicate/gapped ordering, a placeholder database_id, and
DROP TABLE/DROP COLUMN/unfiltered DELETE in one file). All three
checks correctly detected every planted issue with the expected exit code
(2). Source-only release for now — not yet published to the npm registry
(the npx d1-migration-guard form in earlier drafts of this README doesn't
work until that happens).
wrangler d1 execute --local) — gated on this free CLI validating demand first.MIT
5 commits
HTML
52.3%
JavaScript
47.7%