d1-drizzle-schema

Generate Drizzle ORM schemas and migrations for Cloudflare D1 databases.

3|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/langgenius/due-date-hq-jwl --skill d1-drizzle-schema-langgenius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: d1-drizzle-schema
Source: https://github.com/langgenius/due-date-hq-jwl/tree/main/.agents/skills/d1-drizzle-schema
Command: npx skills add https://github.com/langgenius/due-date-hq-jwl --skill d1-drizzle-schema-langgenius

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 behaves differently from standard SQLite: foreign keys are always enforced, there are no native BOOLEAN or DATETIME types, and queries are limited to 100 bound parameters. Using standard SQLite patterns with Drizzle ORM causes subtle bugs, failed bulk inserts, and broken migrations. This Skill generates schemas that are correct for D1 from the start. ## Core Features & Use Cases - D1-Correct Schema Generation: Produces Drizzle schema files using the right column patterns, such as integer with boolean mode for booleans, integer with timestamp mode for dates, and text with json mode for typed JSON. - Migration and Config Scaffolding: Outputs a drizzle.config.ts template, wrangler migration commands for local and remote databases, and batch insert logic that respects the 100 bound parameter limit. - Documentation Output: Generates a DATABASE_SCHEMA.md file documenting tables, relationships, indexes, and the migration workflow for future sessions. - Use Case: When adding a new table to a Cloudflare Workers project backed by D1, use this Skill to scaffold the table definition, relations, type exports, and migration scripts without hitting D1-specific pitfalls. ## Quick Start Ask the AI to generate a Drizzle schema for a new Cloudflare D1 database with users and posts tables, including migration commands and type exports.

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 column 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 with Drizzle?

D1 has no native BOOLEAN or DATETIME types. Use integer with mode 'boolean' for true/false values stored as 0/1, and integer with mode 'timestamp' for dates stored as unix epoch seconds. Drizzle automatically converts these to JavaScript boolean and Date types.

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

D1 limits each query to 100 bound parameters, unlike standard SQLite's roughly 999. Calculate batch size as Math.floor(100 divided by columns per row) and insert in chunks. Exceeding the limit causes silent failures or cryptic insert errors.

Does Cloudflare D1 enforce foreign keys?

Yes, D1 always enforces foreign keys and blocks PRAGMA foreign_keys toggles. Define references with onDelete options like cascade or set null in your Drizzle schema, and use PRAGMA defer_foreign_keys in migrations with circular dependencies.

Can I query JSON columns in Cloudflare D1?

Yes, D1 has JSON functions always available, including json_extract, the -> and ->> operators, and json_each. Store JSON as text columns with Drizzle's json mode, and guard queries with json_valid to avoid malformed JSON errors.