database-and-prisma-review

Reviews Prisma schemas, migrations, seeds, and data-access code for destructive changes and N+1 queries.

2|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/FluxonLab/Skillry --skill database-and-prisma-review-fluxonlab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-and-prisma-review
Source: https://github.com/FluxonLab/Skillry/tree/main/plugins/database-and-data/skills/35-database-and-prisma-review
Command: npx skills add https://github.com/FluxonLab/Skillry --skill database-and-prisma-review-fluxonlab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Database schema changes can silently destroy production data through dropped columns, unsafe type narrowing, or non-nullable columns added without backfills. This Skill inspects Prisma schemas, migration history, seed scripts, and data-access code to flag destructive operations as blocking before they reach staging or production. ## Core Features & Use Cases - Migration Safety Review: Classifies every migration statement as safe, unsafe, or destructive, detects drift with prisma migrate status, and enforces expand-contract patterns for breaking changes. - Query Pattern Analysis: Detects N+1 query loops, unbounded findMany() calls, missing foreign-key indexes, and upserts lacking unique constraints. - Seed & Fixture Auditing: Verifies seed idempotency (upsert over create), deterministic test data, and environment guards preventing resets against shared databases. - Use Case: Before merging a PR that edits schema.prisma, run this review to catch a column rename that Prisma would treat as drop-plus-add, and receive a hand-written RENAME COLUMN migration as the safe alternative. ## Quick Start Review my schema.prisma file and the latest migration in prisma/migrations for any destructive changes or data-loss risks before I deploy.

Frequently Asked Questions about database-and-prisma-review

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

FAQPage Schema
How do I review a Prisma migration for data loss before deploying?▼

Run `prisma migrate status` to detect drift, then scan the migration SQL for destructive verbs like DROP COLUMN, SET NOT NULL, or RENAME. Classify each statement as safe, unsafe, or destructive, and rewrite risky changes using the expand-contract pattern with batched backfills.

How to fix N+1 queries in Prisma applications?▼

Replace loops calling findUnique per row with a single findMany using include or select to fetch relations. For unbounded queries, add take and cursor pagination instead of loading entire tables into memory.

What is the difference between prisma migrate dev and migrate deploy?▼

prisma migrate dev creates and applies migrations in local development only, while migrate deploy applies existing migrations in CI/CD and production. Never run migrate dev or migrate reset against staging or production databases.

Why does adding a required column fail on a populated table?▼

A non-nullable column without a default or backfill fails because existing rows have no value. Add the column as nullable, backfill data in batches, then enforce NOT NULL in a later migration to avoid table locks.

How do I make Prisma seed scripts idempotent?▼

Use upsert instead of create so re-running the seed updates existing rows rather than failing on duplicates. Ensure every upsert targets a field backed by a @unique or @@unique constraint to prevent duplicate inserts under concurrency.

When should I not use this Prisma review skill?▼

Skip it for tasks unrelated to database persistence, pure query performance tuning (use a query performance review instead), or non-Prisma databases where a Prisma-specific lens does not apply. It reviews code but never executes destructive commands.