Drizzle Postgres
Build type-safe PostgreSQL applications using Drizzle ORM with guidance on schema design, migrations, and query optimization. Covers essential patterns for relationships, transactions, and connection pooling alongside performance best practices like indexing foreign keys and avoiding N+1 queries.
Drizzle Postgres helps you set up type-safe PostgreSQL databases with Drizzle ORM, covering schemas, migrations, and query patterns.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-07-26
Drizzle Postgres helps you set up type-safe PostgreSQL databases with Drizzle ORM, covering schemas, migrations, and query patterns. Build type-safe PostgreSQL applications using Drizzle ORM with guidance on schema design, migrations, and query optimization. Covers essential patterns for relationships, transactions, and connection pooling alongside performance best practices like indexing foreign keys and avoiding N+1 queries.
Use it when
- Drizzle Postgres setup begins with installing dependencies: drizzle-orm, drizzle-kit, and your chosen PostgreSQL driver.
- Drizzle Postgres schemas are defined using table() and column type functions in TypeScript files.
Install
pedronauck/skills/drizzle-postgres · repository language: JavaScript
generated, unverified - the skill's exact subdirectory could not be determined; check the repository on GitHub
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I use drizzle with postgres?
Drizzle Postgres enables type-safe PostgreSQL development through a lightweight ORM. Start by installing the drizzle-orm package and a PostgreSQL driver (node-postgres or postgres.js). Configure your database connection, define your schema using Drizzle's table definitions, and use the generated types for queries. Drizzle Postgres provides a query builder API that catches schema errors at compile time, reducing runtime bugs and improving developer experience.
What's the best way to set up Drizzle Postgres for a new project?
Drizzle Postgres setup begins with installing dependencies: drizzle-orm, drizzle-kit, and your chosen PostgreSQL driver. Create a schema file defining your tables with columns, types, and relationships. Configure drizzle.config.ts with your database credentials and schema path. Use drizzle-kit generate to create migrations, then drizzle-kit migrate to apply them. This approach ensures your database schema stays in sync with your TypeScript definitions and maintains type safety throughout your application.
How do I define database schemas and relationships with Drizzle?
Drizzle Postgres schemas are defined using table() and column type functions in TypeScript files. Define primary keys with primaryKey(), foreign keys with references(), and relationships using relations(). For example, a users table might reference a posts table via a userId foreign key. Drizzle Postgres automatically generates migrations and provides type-safe relation queries. Relations enable eager loading and prevent N+1 query problems through proper query composition and join strategies.
What are the key steps for executing database migrations in Drizzle?
Drizzle Postgres migrations are managed through drizzle-kit. After modifying your schema, run drizzle-kit generate to create migration files comparing your schema to the database state. Review generated SQL for accuracy, then execute drizzle-kit migrate to apply changes to PostgreSQL. Drizzle Postgres tracks applied migrations in a __drizzle_migrations__ table, enabling safe rollbacks and multi-environment deployment. Always test migrations in development before production use.
What performance best practices should I follow with Drizzle Postgres?
Drizzle Postgres performance depends on proper indexing, connection pooling, and query optimization. Index foreign keys and frequently queried columns to accelerate lookups. Use connection pooling (via PgBoss or similar) to manage database connections efficiently. Avoid N+1 queries by using Drizzle's relation queries and batch operations. Monitor query execution with EXPLAIN ANALYZE. Leverage Drizzle Postgres's type safety to catch inefficient patterns early, and use transactions for data consistency in multi-step operations.
How does Drizzle Postgres handle type-safe queries and relationships?
Drizzle Postgres generates TypeScript types directly from your schema definitions, ensuring queries are checked at compile time. When you define relations between tables, Drizzle Postgres provides type-safe query methods that prevent selecting non-existent columns or joining incompatible tables. The query builder API guides you through valid operations, and IDE autocomplete surfaces available fields and relations. This eliminates entire classes of runtime errors common in traditional ORMs and raw SQL approaches.
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Set up and configure Drizzle ORM for PostgreSQL databases”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Build type-safe database applications pairing PostgreSQL with Drizzle ORM. This skill covers schema design, relational queries, migrations via drizzle-kit, connection pooling, and common performance pitfalls like N+1 queries and missing indexes. Includes decision trees for modeling relationships and diagnosing slow queries.
This skill covers Drizzle ORM fundamentals for building type-safe database layers, including schema organization, prepared statements, and transaction patterns. Learn performance-first practices like indexing strategies, N+1 prevention, and safe migration workflows using package scripts. Covers common pitfalls and validation steps to ensure robust database code.
This skill guides you through Drizzle ORM's migration workflow for SQLite databases, covering schema definition, column types, and common changes like adding tables or indexes. Learn production-ready strategies for generating migrations, applying them in code, and managing relations between tables.
This skill covers Drizzle ORM usage in the `@internal/dashboard-agent-db` package, the agent's dedicated conversation store. Learn schema definition with pg-core, postgres.js driver configuration, drizzle-kit migrations, and the repo's access-pattern query layer enforcing tenant scoping and foreign-key-free design. Drizzle is isolated from the main Prisma database.
Drizzle ORM is a lightweight, type-safe TypeScript ORM that treats SQL as a first-class citizen. This skill covers schema definition, database connections across PostgreSQL, SQLite, and Turso, relational queries, and performance patterns like proper indexing and pagination.
Drizzle is a TypeScript-first ORM built for compile-time type safety and edge-runtime performance. Define schemas with SQL-like syntax, execute queries with full type inference, and manage one-to-many and many-to-many relations without runtime dependencies.
More skills Drizzle Orm (unlicensed) · drizzle-orm-d1 (MIT) · drizzle-orm-patterns (MIT) · Database Design (unlicensed)