d1-drizzle-schema

Generate D1-compatible Drizzle ORM schemas with D1-specific column types and constraints.

Updated May 23, 2026
One-click install
npx skills add https://github.com/devturco/thiago-dev-template --skill d1-drizzle-schema-devturco
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: d1-drizzle-schema
Source: https://github.com/devturco/thiago-dev-template/tree/main/.claude/skills/d1-drizzle-schema
Command: npx skills add https://github.com/devturco/thiago-dev-template --skill d1-drizzle-schema-devturco

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

D1’s Cloudflare-specific SQLite constraints (always-on foreign keys, no native BOOLEAN/DATETIME, strict bound-parameter and size limits) can silently break standard Drizzle/SQLite schemas unless you generate D1-aware patterns.

Core Features & Use Cases

  • Generate D1-correct Drizzle ORM schemas with proper column types and constraints (e.g., BOOLEAN via integer({ mode: 'boolean' }), timestamps via integer({ mode: 'timestamp' })).
  • Produce migration-ready guidance and documentation, including migration command suggestions and a DATABASE_SCHEMA.md content plan.
  • Model relationships and indexing safely for D1, including correct FK handling and common indexing patterns that align with D1 behavior.
  • Use Case: scaffold a new D1 data layer (tables, relations, indexes, and exports) so your Worker code can query with correct types and avoid runtime edge-case failures.

Quick Start

Ask the skill to generate a D1-compatible Drizzle schema (tables, foreign keys, indexes, relations, and type exports) from your data model description.

Frequently Asked Questions about d1-drizzle-schema

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

FAQPage Schema
How do I generate a Drizzle schema for Cloudflare D1 that avoids migration errors?

Generate D1-compatible Drizzle ORM schemas by applying integer modes for BOOLEAN and DATETIME emulation, ensuring always-enforced foreign keys, and tracking the 100 bound-parameter limit to prevent migration errors.

Why does my standard SQLite Drizzle schema break when deployed to Cloudflare D1?

Standard SQLite Drizzle schemas break on D1 because D1 always enforces foreign keys, lacks native BOOLEAN and DATETIME types, and imposes strict bound-parameter limits, causing silent runtime failures without D1-aware schema patterns.

How do I handle boolean and timestamp columns in a Drizzle D1 schema?

Handle boolean and timestamp columns in a Drizzle D1 schema by defining them as integers using specific modes: `integer({ mode: 'boolean' })` for booleans and `integer({ mode: 'timestamp' })` for dates, ensuring correct type emulation.

Can I define foreign keys and indexes safely with Drizzle ORM for Workers?

Yes, you can define foreign keys and indexes safely for Workers by modeling relationships according to D1's always-enforced foreign key constraints and applying indexing patterns that align with D1 behavior to avoid runtime failures.

What is the bound-parameter limit for Cloudflare D1 queries and how does it affect schema generation?

Cloudflare D1 enforces a 100 bound-parameter limit per query. D1-aware schema generation accounts for this strict limit by structuring data layer definitions to prevent query failures during runtime operations.

How do I scaffold a D1 data layer with Drizzle ORM for my Workers app?

Scaffold a D1 data layer by generating D1-compatible Drizzle schemas with tables, relations, indexes, and type exports from your data model description, alongside migration command guidance and DATABASE_SCHEMA.md documentation.