drizzle-orm-d1

Build type-safe Drizzle ORM schemas and migrations for Cloudflare D1.

961|99|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/jezweb/claude-skills --skill drizzle-orm-d1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle-orm-d1
Source: https://github.com/jezweb/claude-skills/tree/main/skills/drizzle-orm-d1
Command: npx skills add https://github.com/jezweb/claude-skills --skill drizzle-orm-d1

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill eliminates 12 common database errors and provides production-tested patterns for Drizzle ORM with Cloudflare D1, saving developers hours of debugging and setup time.

Core Features & Use Cases

  • Type-Safe Queries: Full TypeScript inference for all database operations, preventing type errors.
  • Migration Management: Automatically generate and apply database migrations with proper D1 compatibility.
  • Use Case: Imagine you're building a Cloudflare Worker that needs a database. Use this Skill to create a complete type-safe schema, manage migrations, and implement complex relations with zero raw SQL.

Quick Start

Install Drizzle ORM and Drizzle Kit, then define your schema in src/db/schema.ts and generate migrations with drizzle-kit generate.

Error Prevention

Prevents 12 documented issues including D1 transaction errors, foreign key constraint failures, and migration apply errors.

Frequently Asked Questions about drizzle-orm-d1

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

FAQPage Schema
How do I build type-safe database queries with Drizzle ORM on Cloudflare D1?

Drizzle ORM provides full TypeScript inference for D1 queries, eliminating type errors. Define your schema in src/db/schema.ts, generate migrations with drizzle-kit generate, and write queries with complete type safety. This prevents runtime errors and ensures all database operations are validated at compile time.

Can I use Drizzle ORM to manage database migrations on Cloudflare D1?

Yes. Drizzle Kit automatically generates and applies D1-compatible migrations from your schema definitions. This eliminates manual SQL migration errors and ensures migrations work reliably in Cloudflare Workers environments without transaction failures or foreign key constraint issues.

What's the best way to handle database transactions and batch operations in D1?

Use the D1 batch API through Drizzle ORM to group multiple operations into single transactions. This Skill provides production-tested patterns for implementing batch operations, preventing common D1 transaction errors and ensuring data consistency in your Cloudflare Workers applications.

Does Drizzle ORM support complex database relations on Cloudflare D1?

Yes. Drizzle ORM supports defining and querying complex relations with full TypeScript type safety. The Skill covers implementing relations properly with D1, including constraint configuration and avoiding foreign key failures that commonly occur in Workers environments.

How do I troubleshoot common Cloudflare D1 errors when using Drizzle ORM?

This Skill documents and prevents 12 common D1 errors including transaction failures, constraint violations, and migration apply errors. It provides production-grade error prevention patterns and debugging guidance specific to D1 and Cloudflare Workers integration.

Do I need raw SQL when building D1 applications with Drizzle ORM?

No. Drizzle ORM eliminates the need for raw SQL through type-safe schema definitions, query builders, and prepared statements. This approach prevents SQL errors and maintains type safety throughout your entire database layer in Cloudflare Workers.