Drizzle ORM Skill

Implement type-safe Drizzle ORM schemas, queries, and migrations in Next.js.

Updated Nov 4, 2025
One-click install
npx skills add https://github.com/putto11262002/jimmodel --skill drizzle-orm-skill
Or copy as Structured Prompt for Agentâ–¼
Please help me install this Agent Skill.
Skill: Drizzle ORM Skill
Source: https://github.com/putto11262002/jimmodel/tree/main/.claude/skills/drizzle-orm
Command: npx skills add https://github.com/putto11262002/jimmodel --skill drizzle-orm-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Working with ORMs and databases can be complex, involving schema definitions, query writing, and migration management. This skill provides expert guidance and project conventions for Drizzle ORM, ensuring type-safe, efficient, and maintainable database operations within a Next.js project.

Core Features & Use Cases

  • Schema Definition Guide: Comprehensive patterns for defining tables, columns, relations, and indexes with type safety.
  • Data Access Patterns: Best practices for writing SELECT, INSERT, UPDATE, and DELETE queries, including joins and transactions.
  • Migration Workflow: Explains the process for generating and applying database migrations, ensuring schema evolution is smooth.
  • Use Case: You need to add a new user_profiles table with a foreign key to users. Use this skill to define the schema correctly, including timestamps and indexes, and understand the migration steps.

Quick Start

Help me define a new 'user_profiles' table with a foreign key to the 'users' table.

Frequently Asked Questions about Drizzle ORM Skill

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

FAQPage Schema
How do I set up type-safe database queries with Drizzle ORM in Next.js?â–¼

Drizzle ORM provides type-safe queries by defining schemas in TypeScript, automatically inferring column types and relationships. Define your tables using Drizzle's schema API, then write queries that receive full type inference without runtime validation overhead.

How do I create and apply database migrations with Drizzle ORM?â–¼

Generate migrations by modifying your schema definition, then run Drizzle's migration CLI to create migration files tracking schema changes. Apply migrations to evolve your database while maintaining an auditable history of structural changes.

Can I use Drizzle ORM with PostgreSQL in a Next.js project?â–¼

Yes, Drizzle ORM fully supports PostgreSQL and integrates seamlessly with Next.js server-side code. Configure your database connection in your Next.js project and define schemas using Drizzle's PostgreSQL-specific types and features.

What's the best way to handle foreign keys and relationships in Drizzle ORM schemas?â–¼

Drizzle ORM lets you define foreign key relationships directly in schema definitions using relation helpers. This enables type-safe joins and relationship queries while maintaining referential integrity at the database level.

Do I need to write raw SQL when using Drizzle ORM for complex queries?â–¼

Drizzle ORM supports SELECT, INSERT, UPDATE, and DELETE operations including joins and transactions through its query builder, reducing raw SQL need. For truly complex scenarios, you can fall back to raw SQL while maintaining type safety through explicit typing.

How do I ensure my database layer follows best practices in Next.js with Drizzle ORM?â–¼

Drizzle ORM supports server-only execution, enabling you to isolate database access to server components and API routes. Follow patterns for consistent query structure, use transactions for multi-step operations, and leverage Drizzle's type inference to catch errors at development time.