d1-drizzle-schema

Generates Drizzle ORM schemas for Cloudflare D1 databases with D1-specific column patterns and migrations.

1|Updated Aug 18, 2026
One-click install
npx skills add https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent --skill d1-drizzle-schema-scsm-unrestrict
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: d1-drizzle-schema
Source: https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent/tree/main/frontend-engineer/skills/d1-drizzle-schema
Command: npx skills add https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent --skill d1-drizzle-schema-scsm-unrestrict

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires drizzle-orm, drizzle-kit, wrangler, and includes references (resource) and assets (resource) components.

What problem does it solve? Cloudflare D1 is SQLite-based but differs from standard SQLite in ways that cause subtle bugs: foreign keys are always enforced, there are no native BOOLEAN or DATETIME types, bound parameters are capped at 100, and JSON is stored as TEXT. This Skill generates Drizzle ORM schemas that correctly handle all of these D1 quirks instead of producing schemas that fail silently at runtime. ## Core Features & Use Cases - D1-Correct Schema Generation: Produces schema files using proper patterns such as integer with boolean mode, integer timestamps, typed JSON text columns, UUID primary keys, and enforced foreign keys. - Migration and Config Scaffolding: Provides a drizzle.config.ts template, package.json migration scripts for local and remote wrangler d1 commands, and batch insert logic that respects the 100 bound parameter limit. - Documentation Output: Generates a DATABASE_SCHEMA.md documenting tables, relationships, indexes, and the migration workflow for future sessions. - Use Case: When scaffolding a new Cloudflare Workers project with a D1 database, use this Skill to generate the full data layer including schema.ts, relations, type exports, drizzle config, and migration commands in one pass. ## Quick Start Ask the agent to create a Drizzle schema for a new Cloudflare D1 database with users and posts tables, including relations, type exports, and migration scripts.

Frequently Asked Questions about d1-drizzle-schema

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

FAQPage Schema
How do I create a Drizzle ORM schema for Cloudflare D1?

Define tables with sqliteTable from drizzle-orm/sqlite-core using D1-correct patterns: text UUID primary keys, integer with boolean mode for booleans, integer with timestamp mode for dates, and text with json mode for JSON. Then run drizzle-kit generate and apply migrations with wrangler d1 migrations apply.

How do I store booleans and dates in Cloudflare D1?

D1 has no native BOOLEAN or DATETIME types. Use integer('col', { mode: 'boolean' }) for booleans, stored as 0/1, and integer('col', { mode: 'timestamp' }) for dates, stored as unix epoch seconds. Drizzle automatically converts these to JavaScript boolean and Date types.

Does Cloudflare D1 enforce foreign keys?

Yes, D1 always enforces foreign keys and they cannot be disabled with PRAGMA foreign_keys. Define references with onDelete behaviors like cascade or set null, and use PRAGMA defer_foreign_keys at the start of migrations when tables have circular foreign key dependencies.

Why does my D1 bulk insert fail or insert partial data?

D1 limits bound parameters to 100 per query, so large inserts silently fail or partially complete. Calculate batch size as Math.floor(100 / columns_per_row) and insert rows in chunks, for example 20 rows per insert for a 5-column table.

Can I query JSON columns in Cloudflare D1 with SQL?

Yes, D1 always has JSON functions available including json_extract, the -> and ->> operators, and json_each. Guard queries with json_valid() because json_extract throws a malformed JSON error on non-JSON text. You can also create generated columns from JSON fields for indexing.