prisma-multi-tenant

Implements tenant-isolated Prisma queries and migrations on Neon PostgreSQL.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/gengirish/dropflow --skill prisma-multi-tenant-gengirish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-multi-tenant
Source: https://github.com/gengirish/dropflow/tree/main/.cursor/skills/prisma-multi-tenant
Command: npx skills add https://github.com/gengirish/dropflow --skill prisma-multi-tenant-gengirish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires prisma, @prisma/client, @paralleldrive/cuid2.

What problem does it solve? Multi-tenant applications risk data leaks when queries forget to filter by tenant, and serverless deployments on Neon PostgreSQL require different connection strategies than long-running workers. This Skill enforces tenant isolation at the Prisma client level and standardizes migrations, IDs, and connection configuration. ## Core Features & Use Cases - Automatic Tenant Isolation: A Prisma client extension injects tenantId into every find, create, update, and delete operation so queries can never cross tenant boundaries. - Neon Connection Management: Separate pooled and direct connection URLs for Vercel serverless functions, Fly.io workers, and migrations. - Migration & Branch Workflows: Standard commands for creating and deploying migrations, plus Neon branch workflows for testing schema changes per feature. - Use Case: When adding a new Order model to a SaaS app, use this Skill to define the schema with cuid2 IDs and tenantId, run prisma migrate dev against a Neon branch, and query it safely through getTenantPrisma(). ## Quick Start Ask the AI to add a new Prisma model with tenant isolation and generate the migration for the Neon database.

Frequently Asked Questions about prisma-multi-tenant

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

FAQPage Schema
How do I enforce tenant isolation in Prisma queries?▼

Use a Prisma client extension via `$extends` that intercepts all model operations and injects `tenantId` into every where clause and create payload. Wrap this in a factory like `getTenantPrisma(tenantId)` so all queries are automatically scoped to one tenant.

How to run Prisma migrations with Neon PostgreSQL?▼

Run `pnpm prisma migrate dev` for development and `prisma migrate deploy` for production, always using the direct (non-pooled) Neon connection URL. Pooled connections are only for serverless query traffic, not migrations.

Should I use pooled or direct Neon connection for Prisma?▼

Use the pooled URL (`*.pooler.neon.tech`) for Vercel serverless functions to handle connection limits, and the direct URL for long-running Fly.io workers and all migrations. Configure both via `url` and `directUrl` in the datasource block.

Can Prisma middleware enforce tenantId on findUnique queries?▼

Yes, a `$allModels` query extension can inject `tenantId` into findUnique, update, and delete where clauses, though a type cast may be needed since those operations expect unique fields. This prevents cross-tenant reads even on single-record lookups.

Why should money fields be Int instead of Float in Prisma?▼

Storing money as Int in the smallest currency unit (paise) avoids floating-point rounding errors that occur with Float or Decimal types. This convention ensures exact arithmetic for financial calculations across all tenant records.