prisma-conventions

Enforce Prisma ORM conventions for schema, migrations, and raw SQL.

1|Updated Jun 24, 2026
One-click install
npx skills add https://github.com/eric-sabe/engsys --skill prisma-conventions-eric-sabe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-conventions
Source: https://github.com/eric-sabe/engsys/tree/main/stacks/db/prisma/skills/prisma-conventions
Command: npx skills add https://github.com/eric-sabe/engsys --skill prisma-conventions-eric-sabe

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates hard-to-debug Prisma ORM pitfalls that cause runtime failures and incorrect database behavior, including unsupported partial unique constraints, raw SQL mapped name mismatches, and unhandled P2002 unique constraint violations.

Core Features & Use Cases

  • Partial Unique Constraint Guidance: Provides steps to implement conditional unique indexes Prisma's schema DSL does not support, including writing custom migration SQL and handling violations in the service layer.
  • Raw SQL Name Correctness: Enforces use of database-mapped @@map/@map table and column names in $queryRaw/$executeRaw queries to avoid "relation does not exist" runtime errors.
  • P2002 Error Debugging: Offers clear troubleshooting steps for unique constraint violation errors and relation not found issues when working with Prisma.
  • Use Case: When building a multi-tenant application with unique slugs per active tenant, this Skill guides you to create a filtered unique index via custom migration instead of misusing Prisma's unconditional @@unique, and ensures your raw analytics queries reference the correct mapped table names.

Quick Start

Ask the prisma-conventions skill to review your Prisma schema, migrations, and raw SQL queries to catch mapped name mismatches and invalid constraint definitions before they cause runtime errors.

Frequently Asked Questions about prisma-conventions

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

FAQPage Schema
How do I create a partial unique constraint in Prisma when schema DSL does not support it?

To create a partial unique constraint in Prisma, write custom migration SQL to generate a filtered unique index, then handle constraint violations in the service layer. Prisma schema DSL does not support conditional unique indexes natively.

Why does Prisma raw SQL return a relation does not exist error?

Prisma raw SQL returns a relation does not exist error when queries use Prisma model names instead of database-mapped names. Enforce correct @@map and @map values in $queryRaw or $executeRaw statements to match actual database table and column names.

How do I debug Prisma P2002 unique constraint violation errors?

Debug Prisma P2002 unique constraint violation errors by reviewing your schema definitions and custom migration indexes. Implement service-layer error handling to catch and resolve these specific runtime failures during database operations.

Can I use conditional unique indexes for multi-tenant applications in Prisma?

Yes, you can use conditional unique indexes for multi-tenant applications in Prisma by writing custom migration SQL. This avoids misusing unconditional @@unique and ensures unique slugs per active tenant.

What is the best way to prevent Prisma ORM runtime failures and schema mismatches?

The best way to prevent Prisma ORM runtime failures is to review schema.prisma authoring, migration creation, and generated client usage. Ensure raw SQL queries reference mapped table names and validate constraint definitions.