cloudflare-d1-drizzle-migration

Review Cloudflare D1 Drizzle migrations for unsafe table rebuilds and cascades.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/okayus/okayus-skills --skill cloudflare-d1-drizzle-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudflare-d1-drizzle-migration
Source: https://github.com/okayus/okayus-skills/tree/main/skills/cloudflare-d1-drizzle-migration
Command: npx skills add https://github.com/okayus/okayus-skills --skill cloudflare-d1-drizzle-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents destructive Cloudflare D1 database migrations that can silently delete related production data when drizzle-kit table rebuilds interact with SQLite foreign key cascades.

Core Features & Use Cases

  • Migration Safety Audits: Detect risky drizzle-kit generated migrations involving table rebuilds, constraint changes, and foreign key cascade behavior before deployment.
  • Production Data Protection: Provides backup, row-count verification, restore procedures, and phased migration strategies for live D1 databases.
  • Use Case: When changing a Drizzle schema from nullable to NOT NULL on a production table with child relationships, use this Skill to plan a safe multi-phase rollout and avoid accidental cascade deletions.

Quick Start

Use the cloudflare-d1-drizzle-migration skill to review my upcoming Drizzle migration and provide a safe deployment plan for Cloudflare D1.

Frequently Asked Questions about cloudflare-d1-drizzle-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Cloudflare D1 migration delete related data when using drizzle-kit?

Cloudflare D1 migrations delete related data because drizzle-kit table rebuilds interact destructively with SQLite foreign key cascades during schema changes. This Skill audits generated migrations to prevent silent cascade deletions before deployment.

How do I safely change a Drizzle schema column to NOT NULL on a production D1 database?

Safely changing a Drizzle schema to NOT NULL on D1 requires a phased rollout strategy including migration review, backups, and row-count validation. This Skill generates the deployment plan to avoid accidental data loss.

Can I use this for Cloudflare Workers projects using SQLite D1 and foreign keys?

Yes, this is designed for Cloudflare Workers projects using Drizzle ORM, drizzle-kit, and SQLite D1. It reviews production schema changes involving constraints, types, renames, and foreign keys to ensure data safety.

What is the best way to backup and restore a D1 database before a risky migration?

The best way to backup and restore D1 before risky migrations is using structured backup procedures and restore runbooks. This Skill provides row count validation and restore protocols to verify data integrity.

How do I detect risky table rebuilds in my drizzle-kit generated migrations?

Detect risky table rebuilds by auditing drizzle-kit generated migrations for constraint changes and foreign key cascade behavior. This Skill analyzes migration scripts to identify destructive operations before they reach production.

What are the limitations of relying on drizzle-kit for SQLite D1 schema migrations?

Relying on drizzle-kit for SQLite D1 schema migrations risks destructive table rebuilds and accidental foreign key cascade deletions. This Skill mitigates these limitations by enforcing migration reviews and phased schema rollouts.