@tank/drizzle-orm-mastery
Installation
SKILL.md
Drizzle ORM Mastery
Core Philosophy
- SQL-first, not SQL-hidden -- Drizzle maps 1:1 to SQL. Learn SQL patterns and Drizzle follows. If the query builder feels awkward, write the SQL first, then translate.
- Schema is the source of truth -- TypeScript schema definitions drive migrations, queries, and type inference. Change the schema, regenerate migrations, never hand-edit SQL files.
- Push for prototyping, migrate for production -- Use
drizzle-kit pushduring development for instant schema sync. Switch todrizzle-kit generate+migratebefore deploying to shared environments. - Infer types, never duplicate them -- Extract types from schema with
typeofand$inferSelect/$inferInsert. Manually typed interfaces drift from the actual schema. - Choose the right query API -- Use the SQL-like query builder (
db.select()) for complex queries with joins and subqueries. Use the relational queries API (db.query) for nested object fetching withwith.
Quick-Start: Common Problems
"How do I define a schema?"
import { pgTable, integer, varchar, timestamp } from "drizzle-orm/pg-core";