Claude Skill MartBrowse skillsQuick linesLearn by videoTerminal guideWhat is a Skill?
← Back to list

D1 Migration Workflow

A practical playbook for generating, reviewing, and applying Cloudflare D1 migrations with Drizzle — including recovery from stuck migrations.

Dev & CodingIntermediate★ 1,033⑂ 105AI score 8/10Last updated: Sep 26, 2026

What it does

  • Forces an inspection step on SQL generated by pnpm db:generate, flagging Drizzle's destructive "table recreation" pattern (CREATE new → INSERT SELECT → DROP → RENAME) that appears when you only change a column default, and rewriting it as a simple ALTER TABLE ADD COLUMN.
  • Applies migrations to both local and remote (--local / --remote) and verifies with PRAGMA table_info so you avoid "works locally, breaks in prod".
  • Diagnoses and repairs stuck/partially applied migrations by querying the d1_migrations table and manually recording the missing entry.
  • Provides a batching pattern to avoid D1's silent failure when bulk INSERT exceeds the ~100–150 parameter limit.
  • Documents column naming conventions (Drizzle camelCase vs raw SQL snake_case) and the correct new-project order: deploy Worker → create D1 → copy database_id into wrangler.jsonc → redeploy → migrate.

Who it's for

  • Backend/full-stack developers on Cloudflare Workers + D1 + Drizzle ORM.
  • Teams repeatedly bitten by drifted local vs remote database state.
  • Anyone tired of looking up wrangler d1 CLI syntax.

Examples

  1. You add a column to your Drizzle schema and ask Claude to "generate and apply the migration" — it reads the SQL first, rewrites a table-recreation migration into a safe ALTER, then applies to local and remote.
  2. db:migrate fails with a duplicate column error — Claude checks PRAGMA table_info and d1_migrations, records the stuck migration, and continues the remaining ones.
  3. A 500-row seed insert silently fails — Claude refactors it into a 10-row batched 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/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)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
↓ Download 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 plugins/cloudflare/skills/d1-migration folder from the GitHub repo jezweb/claude-skills into my ~/.claude/skills/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 && cp -r claude-skills/plugins/cloudflare/skills/d1-migration ~/.claude/skills/

⚠ This is a third-party skill. Check the source repository before installing.

  1. Install Claude Code and open a terminal.
  2. Clone the repo: git clone https://github.com/jezweb/claude-skills.git
  3. Create the skills folder: mkdir -p ~/.claude/skills
  4. Copy the skill: cp -r claude-skills/plugins/cloudflare/skills/d1-migration ~/.claude/skills/
  5. Confirm ~/.claude/skills/d1-migration/SKILL.md exists.
  6. Make sure your project has wrangler and Drizzle installed, plus db:generate / db:migrate:local / db:migrate:remote scripts.
  7. Restart Claude Code inside your project and say "generate and apply a D1 migration" to trigger the skill.