drizzle-best-practices

Installation
SKILL.md

Drizzle Best Practices

Non-obvious patterns for Drizzle ORM with PostgreSQL in a T3 Turbo monorepo (packages/db/src/schemas/).


Primary Key Strategy

Type Use when Drizzle
serial / bigserial Internal tables, no external exposure, high insert volume serial('id').primaryKey()
uuid Cross-service IDs, externally visible, need uniqueness across DBs uuid('id').defaultRandom().primaryKey()
cuid2 User-facing slugs, URL-safe, sortable-ish, no UUID collisions text('id').$defaultFn(() => createId()).primaryKey()

cuid2 gotcha: .$defaultFn() is a TypeScript-level default only. It does NOT set a DB-level DEFAULT. If you insert via raw SQL (migrations, seeds), you must supply the value.


Installs
3
First Seen
Aug 2, 2026
drizzle-best-practices — leonardoacosta/skills