drizzle

Defines Drizzle ORM schemas and generates idempotent PostgreSQL migrations.

Updated Jul 17, 2026
One-click install
npx skills add https://github.com/usmangurowa/socialmocks --skill drizzle-usmangurowa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle
Source: https://github.com/usmangurowa/socialmocks/tree/main/.agents/skills/drizzle
Command: npx skills add https://github.com/usmangurowa/socialmocks --skill drizzle-usmangurowa

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing consistent Drizzle ORM table definitions and safe database migrations requires remembering many conventions—naming rules, ID generation, timestamp helpers, index syntax, and idempotent SQL. This Skill encodes all of those conventions so schema and migration work stays uniform and error-free. ## Core Features & Use Cases - Schema Conventions: Enforces plural snake_case tables, snake_case columns, prefixed text IDs via idGenerator, cascade foreign keys, and shared timestamp helpers from _helpers.ts. - Common Patterns: Provides ready-made patterns for primary keys, foreign keys, indexes, junction tables for many-to-many relations, and Zod type inference with createInsertSchema. - Migration Workflow: Guides generating migrations with bun run db:generate, renaming files meaningfully, adding IF NOT EXISTS clauses, and refreshing the client hash with db:generate:client. - Use Case: When adding a new agents table with a many-to-many relation to knowledge bases, follow the documented patterns to define the schema, generate the migration, and make it idempotent. ## Quick Start Ask the AI to create a new Drizzle table schema and generate an idempotent migration for it following the project conventions.

Frequently Asked Questions about drizzle

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

FAQPage Schema
How do I define a Drizzle ORM table schema in PostgreSQL?

Use pgTable with plural snake_case table names and snake_case columns. Define a text primary key with $defaultFn calling idGenerator, spread the shared timestamps helper, and return indexes as an array from the third argument.

How to generate Drizzle migrations with bun?

Run bun run db:generate to create the migration SQL and update the journal metadata. After editing the SQL, run bun run db:generate:client to refresh the hash in migrations.json.

How do I create a many-to-many junction table in Drizzle?

Define a table with foreign key columns referencing both entities using onDelete cascade, then add a composite primaryKey over those columns in the index callback. Include a userId reference and timestamps as needed.

Why should Drizzle migrations use IF NOT EXISTS clauses?

Idempotent clauses like ADD COLUMN IF NOT EXISTS and CREATE INDEX IF NOT EXISTS let migrations run safely multiple times without errors. This prevents failures when migrations are reapplied across environments.

How do I infer TypeScript types from a Drizzle table?

Use $inferInsert and $inferSelect on the table object to derive insert and select types. Combine with createInsertSchema from drizzle-zod to generate Zod validation schemas automatically.