SCHEMA AND QUERY DISCIPLINE
Prisma Standards
Maintain Prisma models, relations, and queries without destabilizing the production database.
Production stability and security notice
Development changes must preserve working functionality, Provider isolation, role-based access, HIPAA auditability, released Mobile compatibility, and integration stability. Never deploy AI-generated or unreviewed code directly to production.
Schema Rules
- Append new models at the end when practical for easier management.
- Modify existing models only when required and approved.
- Add both sides of relations consistently.
- Use field mappings only when database naming requires them.
- Keep enums stable because API and Web code may depend on exact values.
Query Rules
| Topic | Standard |
|---|---|
| findMany | Always include Provider scope and only select data required by the caller. |
| findFirst / findUnique | Do not treat uniqueness as authorization; validate Provider ownership separately. |
| update / delete | Include Provider ownership in the lookup before mutation. |
| include | Avoid loading large related graphs without a clear need. |
| select | Prefer minimum necessary field selection for PHI-sensitive operations. |
| transaction | Use $transaction for dependent writes and sequence updates. |
Generation Command
cd C:\TruecareSystem\API pnpm prisma generate
