drizzle-orm

Implements type-safe SQL queries, schemas, and migrations with Drizzle ORM for TypeScript.

Updated Mar 14, 2026
One-click install
npx skills add https://github.com/Ishaq74/atomic --skill drizzle-orm-ishaq74
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle-orm
Source: https://github.com/Ishaq74/atomic/tree/main/.github/skills/drizzle
Command: npx skills add https://github.com/Ishaq74/atomic --skill drizzle-orm-ishaq74

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires drizzle-orm, drizzle-kit, pg, mysql2, better-sqlite3, and includes references (resource) components.

What problem does it solve? Writing database code in TypeScript often means choosing between unsafe raw SQL and heavy ORM runtimes. This Skill provides patterns for building compile-time type-safe database layers with Drizzle ORM, covering schema definition, relations, queries, transactions, and migrations across PostgreSQL, MySQL, and SQLite. ## Core Features & Use Cases - Type-Safe Schema Definition: Define tables, columns, enums, indexes, and constraints in TypeScript with automatic type inference via $inferSelect and $inferInsert. - Query & Relation Patterns: Build filters, joins, aggregations, CTEs, subqueries, and one-to-many or many-to-many relations with SQL-like syntax. - Migrations & Performance: Generate and apply SQL migrations with Drizzle Kit, configure connection pooling, cursor-based pagination, caching, and edge runtime integration. - Use Case: When building a Next.js or serverless API backed by PostgreSQL, use this Skill to define the schema, write optimized queries with relations, and generate migrations without a heavy ORM runtime. ## Quick Start Ask the AI to define a Drizzle schema for your tables and write a type-safe query with a migration using Drizzle Kit.

Frequently Asked Questions about drizzle-orm

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

FAQPage Schema
How do I define a type-safe schema with Drizzle ORM?

Define tables using pgTable, mysqlTable, or sqliteTable with typed columns like serial, text, and timestamp. Drizzle infers TypeScript types automatically via $inferSelect and $inferInsert, giving compile-time safety without a code generation step.

Drizzle vs Prisma: which ORM should I choose?

Drizzle offers a smaller bundle (~35KB vs ~230KB), faster cold starts, and first-class raw SQL support, making it better for edge and serverless deployments. Prisma suits rapid prototyping and teams less comfortable with SQL.

Does Drizzle ORM support edge runtimes like Cloudflare Workers?

Yes, Drizzle works in edge runtimes through HTTP-based drivers such as neon-http for Vercel Edge and the d1 driver for Cloudflare Workers. These avoid TCP connection pooling by sending each query as an HTTP request.

How do I run migrations with Drizzle Kit?

Configure drizzle.config.ts with your schema path and database credentials, then run drizzle-kit generate to create SQL migration files and drizzle-kit migrate to apply them. You can also introspect an existing database to generate a schema.

How do I avoid N+1 queries in Drizzle?

Use the relational query API with db.query.table.findMany and the with option to fetch relations in one query. Alternatively, apply the DataLoader pattern to batch foreign-key lookups across multiple parent records.

Why is OFFSET pagination slow in Drizzle and what is the alternative?

OFFSET scans all skipped rows, so performance degrades on large datasets. Use cursor-based pagination instead: filter with gt or lt on an indexed id or timestamp column, order by that column, and apply limit.