drizzle

Define and enforce Drizzle ORM schema patterns for PostgreSQL with TypeScript.

Updated Dec 12, 2024
One-click install
npx skills add https://github.com/kingmacth/lobe-chat --skill drizzle-kingmacth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle
Source: https://github.com/kingmacth/lobe-chat/tree/main/.agents/skills/drizzle
Command: npx skills add https://github.com/kingmacth/lobe-chat --skill drizzle-kingmacth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Drizzle ORM Schema Style Guide provides a standardized approach to define database schemas, migrations, and ORM models for PostgreSQL projects using Drizzle, ensuring consistency and maintainability across codebases.

Core Features & Use Cases

  • Configuration: guidance on project layout with drizzle.config.ts, src/database/schemas/, and src/database/migrations/, plus dialect settings.
  • Helper Functions: utilities like timestamptz, createdAt, updatedAt, accessedAt for consistent timestamp handling.
  • Naming Conventions: rules for plural table names and snake_case columns.
  • Column Definitions: patterns for primary keys, foreign keys, timestamps, and indexes.
  • Type Inference: how to derive TypeScript types from defined schemas for insert and select operations.
  • Example Pattern: illustrates typical table definitions and relationships with practical patterns (e.g., referencing users in tables, including timestamps).

Quick Start

Define your database schemas under src/database/schemas, create migrations, and generate ORM models for PostgreSQL with Drizzle.

Frequently Asked Questions about drizzle

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

FAQPage Schema
How do I standardize database schemas and migrations with Drizzle ORM in TypeScript?

Standardize Drizzle ORM schemas by enforcing explicit project layouts, naming conventions like plural table names and snake_case columns, and safe migration practices for PostgreSQL using TypeScript.

What is the best way to handle timestamps in Drizzle ORM schema definitions?

Handle timestamps in Drizzle ORM by using predefined helper functions like timestamptz, createdAt, updatedAt, and accessedAt to ensure consistent timestamp handling across all database tables.

How do I derive TypeScript types from Drizzle ORM schemas for insert and select operations?

Derive TypeScript types from Drizzle ORM schemas using built-in type inference utilities designed to automatically generate typed ORM models for both insert and select database operations.

Does this Drizzle ORM schema pattern require a specific project directory structure?

Yes, this Drizzle ORM pattern requires a specific project layout including a drizzle.config.ts file, a src/database/schemas/ directory, and a src/database/migrations/ directory for proper configuration.

Why use a standardized schema style guide for Drizzle ORM migrations and models?

Use a standardized schema style guide for Drizzle ORM to ensure consistency and maintainability across codebases by enforcing explicit configuration, naming conventions, and safe migration practices.

Can I define primary keys, foreign keys, and indexes using these Drizzle ORM patterns?

Yes, you can define primary keys, foreign keys, timestamps, and indexes using explicit column definition patterns that illustrate typical table relationships for PostgreSQL in Drizzle.