prisma-database-architect

Designs and optimizes Prisma schemas, migrations, and queries for PostgreSQL deployments.

1|Updated Sep 3, 2026
One-click install
npx skills add https://github.com/sabiscore/the-yap-engine --skill prisma-database-architect-sabiscore
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-database-architect
Source: https://github.com/sabiscore/the-yap-engine/tree/main/.ai/skills/prisma-database-architect
Command: npx skills add https://github.com/sabiscore/the-yap-engine --skill prisma-database-architect-sabiscore

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Prisma schemas and queries that work in development often fail in production: unindexed foreign keys cause slow queries, unsafe migrations lock live tables, N+1 patterns exhaust connection pools, and Float fields corrupt monetary values. This Skill applies production-grade rules to every Prisma decision so schemas, migrations, and queries are safe and performant from the start. ## Core Features & Use Cases - Schema Design: Enforces conventions like PascalCase models, cuid IDs, Decimal for money, soft deletes, and @@index on every foreign key and filtered field. - Safe Migrations: Applies the expand-migrate-contract pattern, CREATE INDEX CONCURRENTLY, and multi-deploy strategies for NOT NULL columns on live PostgreSQL databases. - Query Optimization: Diagnoses and fixes N+1 queries with include/select, implements cursor-based pagination, upserts, transactions, and EXPLAIN ANALYZE via $queryRaw. - Connection Pooling: Configures Prisma Accelerate for serverless and sizes connection pools for long-running Fastify servers. - Use Case: A user's invoice listing endpoint times out in production. The Skill identifies an N+1 query, rewrites it with eager loading and selective fields, adds a composite index on (status, dueAt), and ships a CONCURRENTLY index migration that avoids table locks. ## Quick Start Ask the AI to design a Prisma schema for your domain or audit your existing schema and slow queries for production readiness.

Frequently Asked Questions about prisma-database-architect

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

FAQPage Schema
How do I fix N+1 queries in Prisma?▼

Fix N+1 queries in Prisma by replacing per-record findMany calls inside loops with a single query using include or nested select to eager-load relations. Detect them with the Prisma query log or @prisma/instrumentation tracing.

How do I add a NOT NULL column safely in a Prisma migration?▼

Add the column as nullable first, backfill existing rows, then add the NOT NULL constraint in a later deploy. On PostgreSQL 11+, you can do it in one migration by adding the column with a DEFAULT value.

How do I create an index without locking a PostgreSQL table?▼

Use CREATE INDEX CONCURRENTLY in a raw SQL migration. Generate an empty migration with prisma migrate dev --create-only, edit the SQL to add CONCURRENTLY, then apply it so reads and writes are not blocked.

Should I use Prisma Accelerate or PgBouncer for connection pooling?▼

Use Prisma Accelerate for serverless deployments like Next.js on Vercel, keeping DIRECT_URL for migrations. For long-running servers like Fastify, configure connection_limit and pool_timeout in the DATABASE_URL instead.

Why should money fields use Decimal instead of Float in Prisma?▼

Float arithmetic loses cents due to binary floating-point rounding, while Decimal is exact. Define money fields as Decimal @db.Decimal(precision, scale), for example @db.Decimal(12, 2), in the Prisma schema.

When should I use cursor-based pagination instead of offset in Prisma?▼

Use cursor-based pagination for large datasets because offset pagination performs a full scan and slows down at high offsets. Cursor pagination with a cursor id and orderBy stays O(1) regardless of page depth.