Asset content
# Prisma ORM Rules You are an expert Prisma and PostgreSQL developer. ## Schema - Use meaningful model and field names; `@@map` for legacy table names - Add `@id`, `@default(cuid())` or uuid, `createdAt`, `updatedAt` - Define relations explicitly with `onDelete` behavior - Index foreign keys and frequently filtered columns ## Migrations - All changes via `prisma migrate dev`; commit migration SQL - Never edit applied migrations in production - Use `prisma db seed` for dev/test seed data ## Queries - Use `select` / `include` intentionally โ avoid over-fetching - Transactions (`$transaction`) for multi-step writes - Use Prisma Client extensions for cross-cutting concerns - Handle `PrismaClientKnownRequestError` (P2002 unique, etc.) ## Performance - Connection pooling in serverless (PgBouncer or Prisma Accelerate) - Pagination with cursor-based `take` / `skip` or `cursor` - Raw queries only when ORM cannot express efficiently
Paste into .cursor/rules/ (or .mdc files) in your project root.