drizzle_skill

This skill helps you design and migrate PostgreSQL schemas with Drizzle ORM, ensuring type-safe, scalable database models and reliable migrations.
  • TypeScript

70.5k

GitHub Stars

1

Bundled Files

3 weeks ago

Catalog Refreshed

2 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstart where the catalogue uses aiagentskills.

npx veilstart add skill lobehub/lobe-chat --skill drizzle

  • SKILL.md3.3 KB

Overview

This skill is a practical Drizzle ORM schema and database guide for TypeScript projects. It codifies naming, column patterns, timestamp helpers, index usage, and migration best practices to keep schemas consistent and migrations safe. Use it when defining tables, creating migrations, or inferring types from Drizzle tables.

How this skill works

It inspects Drizzle schema files in src/database/schemas/* and provides guidance on table definitions, helper utilities, and common patterns like junction tables. It explains how to define primary keys, foreign keys, timestamps, indexes, and how to generate and harden migrations for PostgreSQL with strict dialect settings. It also shows how to infer TypeScript types from Drizzle tables for safe CRUD operations.

When to use it

  • Creating or updating table definitions under src/database/schemas/
  • Designing many-to-many relationships (junction tables)
  • Adding timestamps, indexes, or foreign keys with cascades
  • Generating and reviewing SQL migrations for Postgres
  • Inferring TypeScript types from Drizzle tables for insert/select operations

Best practices

  • Use plural snake_case for table names and snake_case for columns
  • Prefix IDs to indicate entity type; use uuid for internal tables
  • Spread standard timestamps from helper functions (createdAt, updatedAt, accessedAt)
  • Return arrays for indexes (object style is deprecated); prefer uniqueIndex named explicitly
  • Make migrations idempotent (IF NOT EXISTS / DROP IF EXISTS) and name files meaningfully

Example use cases

  • Define agents table with id text primary key, user reference, config jsonb, and timestamps
  • Create a agents_knowledge_bases junction table with composite primary key and enabled flag
  • Add a new nullable column to users using an idempotent ALTER TABLE ... IF NOT EXISTS migration
  • Generate TypeScript types with createInsertSchema and use $inferInsert / $inferSelect in services
  • Add a unique index over client_id and user_id using the (t) => [...] index pattern

FAQ

Use plural snake_case for tables (e.g., users) and snake_case for columns (e.g., user_id, created_at).

How do I keep migrations safe across environments?

Write idempotent SQL (IF NOT EXISTS, DROP IF EXISTS, CREATE INDEX IF NOT EXISTS) and give migration files meaningful names.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational