Cloudflare D1 Migration Workflow
A guided workflow for generating, reviewing, applying, and repairing Cloudflare D1 migrations with Drizzle ORM.
Dev & CodingIntermediate★ 1,034⑂ 105AI score 8/10Last updated: Sep 29, 2026
What it does
- Enforces reading the generated SQL before applying it, flagging Drizzle's destructive table-recreation pattern (CREATE new → INSERT SELECT → DROP → RENAME) that appears when you only change a column
default, and replacing it with a simpleALTER TABLE ADD COLUMN. - Gives the correct order for applying migrations to both local (
--local) and remote (--remote), plusPRAGMA table_infoverification commands. - Diagnoses and repairs "stuck" migrations (schema change applied but not recorded) by querying and manually inserting into the
d1_migrationstable. - Avoids silent bulk-insert failures caused by D1's ~100–150 parameter limit using a batching loop.
- Documents naming conventions (camelCase in Drizzle schema, snake_case in raw SQL) and the new-project order: deploy Worker → create D1 → wire
database_id→ redeploy → migrate.
Who it's for
- Developers building on Cloudflare Workers + D1 + Drizzle ORM.
- Anyone who has lost hours to "works locally, breaks in production" schema drift.
- Teams that want Claude Code to run and debug migrations for them.
Examples
- "My add-column migration fails on apply" → the skill spots the table-recreation SQL and rewrites it as a single
ALTER TABLE ... ADD COLUMN. - "
db:migratekeeps failing on a migration that looks already applied" → diagnose withPRAGMA table_infoandSELECT * FROM d1_migrations, record it manually, then continue. - "Seeding 500 rows fails silently" → switch to a BATCH_SIZE = 10 chunked insert loop.
· · · Install guide · · ·
Try it now, no install
Paste this into Claude to use the skill without installing anything.
Read the instructions in this file and follow them to help me: https://raw.githubusercontent.com/jezweb/claude-skills/HEAD/archive/plugins/cloudflare/skills/d1-migration/SKILL.md What I want: (describe your task here)
If Claude can't open the link, open it yourself and paste the contents instead.
↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the archive/plugins/cloudflare/skills/d1-migration folder from the GitHub repo jezweb/claude-skills into my ~/.claude/skills/jezweb-d1-migration/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/jezweb/claude-skills.git && mkdir -p ~/.claude/skills/d1-migration && cp -r claude-skills/archive/plugins/cloudflare/skills/d1-migration/* ~/.claude/skills/d1-migration/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the repo:
git clone https://github.com/jezweb/claude-skills.git - Create the skill directory:
mkdir -p ~/.claude/skills/d1-migration - Copy the files:
cp -r claude-skills/archive/plugins/cloudflare/skills/d1-migration/* ~/.claude/skills/d1-migration/ - Make sure the prerequisites exist in your project:
npx wrangler --version(plus your Drizzle config anddb:*scripts). - Restart Claude Code, then ask something like "generate a D1 migration and apply it to local and remote".
- Note: any
--remotecommand touches your production database — validate locally first.
View source on GitHub ↗License: MIT