drizzle-schema

Define type-safe database schemas in TypeScript for Drizzle ORM.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/theslashdojo/dojo --skill drizzle-schema-theslashdojo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle-schema
Source: https://github.com/theslashdojo/dojo/tree/main/nodes/drizzle/schema
Command: npx skills add https://github.com/theslashdojo/dojo --skill drizzle-schema-theslashdojo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Drizzle Schema provides a clear, type-safe way to declare database tables, columns, constraints, indexes, and enums in TypeScript so schemas stay synchronized with application types and can be reliably turned into SQL migrations.

Core Features & Use Cases

  • Dialect support: Author schemas for PostgreSQL, MySQL, and SQLite using dialect-specific table functions and column types.
  • Type safety and inference: Columns and enums map to TypeScript types and provide inferred insert and select shapes for safer queries.
  • Migrations and tooling: Exported schema modules are consumable by drizzle-kit to automatically generate SQL migrations.
  • Use Case: Define users, posts, tags, relations, and indexes in source-controlled TypeScript, then generate migration SQL for CI-driven deployments.

Quick Start

Create a schema file exporting tables for your chosen dialect and run npx drizzle-kit generate to produce migration SQL.

Frequently Asked Questions about drizzle-schema

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

FAQPage Schema
How do I define a type-safe database schema in TypeScript for Drizzle ORM?

You define a type-safe database schema in TypeScript by exporting dialect-specific table functions, columns, constraints, and enums in a schema module. This maps your database structures directly to TypeScript types, providing inferred insert and select shapes for safer queries.

Can I use Drizzle schemas with PostgreSQL, MySQL, and SQLite?

Yes, Drizzle schemas support PostgreSQL, MySQL, and SQLite. You author tables using dialect-specific table functions and column types, ensuring your schema declarations match the specific SQL dialect you are targeting for your backend service.

How do I generate SQL migrations from a TypeScript schema file?

You generate SQL migrations by exporting your schema modules and running the npx drizzle-kit generate command. This automatically translates your TypeScript table definitions, indexes, and foreign keys into SQL migration files for CI-driven deployments.

What is the best way to manage database relations and indexes in TypeScript?

The best way to manage database relations and indexes in TypeScript is to declare them as source-controlled schema modules using an ORM. This keeps your application types synchronized with your database constraints and enables reliable migration generation.

Do I need to manually write SQL migration files when using a TypeScript schema?

No, you do not need to manually write SQL migration files. By defining your tables, enums, and foreign keys in TypeScript and using drizzle-kit, you can automatically generate the SQL migrations needed for your database deployments.

Does Drizzle ORM provide type inference for insert and select operations?

Yes, Drizzle ORM provides type inference for insert and select operations. By mapping columns and enums to TypeScript types, your schema yields inferred shapes that ensure type-safe queries and application-level data validation.