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

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 simple ALTER TABLE ADD COLUMN.
  • Gives the correct order for applying migrations to both local (--local) and remote (--remote), plus PRAGMA table_info verification commands.
  • Diagnoses and repairs "stuck" migrations (schema change applied but not recorded) by querying and manually inserting into the d1_migrations table.
  • 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

  1. "My add-column migration fails on apply" → the skill spots the table-recreation SQL and rewrites it as a single ALTER TABLE ... ADD COLUMN.
  2. "db:migrate keeps failing on a migration that looks already applied" → diagnose with PRAGMA table_info and SELECT * FROM d1_migrations, record it manually, then continue.
  3. "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)
  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 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.

  1. Open a terminal and clone the repo: git clone https://github.com/jezweb/claude-skills.git
  2. Create the skill directory: mkdir -p ~/.claude/skills/d1-migration
  3. Copy the files: cp -r claude-skills/archive/plugins/cloudflare/skills/d1-migration/* ~/.claude/skills/d1-migration/
  4. Make sure the prerequisites exist in your project: npx wrangler --version (plus your Drizzle config and db:* scripts).
  5. Restart Claude Code, then ask something like "generate a D1 migration and apply it to local and remote".
  6. Note: any --remote command touches your production database — validate locally first.