New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Migration workflow for Cloudflare D1 that generates with Drizzle and flags destructive SQL before applying.

skills.sh installs
1.2K
GitHub stars
1.1K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers generating, inspecting, applying, and verifying D1 migrations across local and remote databases
  • Includes fixes for stuck migrations, duplicate-column failures, and batching large bulk inserts past D1's parameter limit
  • Enforces a rule to read generated SQL first, since column default changes can trigger destructive table recreation
  • Designed for teams using Drizzle ORM on Cloudflare D1 who need to set up or repair schemas

Install

$ npx -y skills add jezweb/claude-skills --skill d1-migration -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

D1 Migration Workflow

Guided workflow for Cloudflare D1 database migrations using Drizzle ORM.

Standard Migration Flow

1. Generate Migration

pnpm db:generate

This creates a new .sql file in drizzle/ (or your configured migrations directory).

2. Inspect the SQL (CRITICAL)

Always read the generated SQL before applying. Drizzle sometimes generates destructive migrations for simple schema changes.

Red Flag: Table Recreation

If you see this pattern, the migration will likely fail:

CREATE TABLE `my_table_new` (...);
INSERT INTO `my_table_new` SELECT ..., `new_column`, ... FROM `my_table`;
--                                      ^^^ This column doesn't exist in old table!
DROP TABLE `my_table`;
ALTER TABLE `my_table_new` RENAME TO `my_table`;

Cause: Changing a column's default value in Drizzle schema triggers full table recreation. The INSERT SELECT references the new column from the old table.

Fix: If you're only adding new columns (no type/constraint changes on existing columns), simplify to:

ALTER TABLE `my_table` ADD COLUMN `new_column` TEXT DEFAULT 'value';

Details

Repository
github.com/jezweb/claude-skills
Categories
Databases, Backend & APIs
First seen
May 16, 2026

More from jezweb/claude-skills

All 64

Similar to D1 Migration

More Databases