True Care SystemTrue Care SystemDocumentation
Return to Website

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

TopicStandard
findManyAlways include Provider scope and only select data required by the caller.
findFirst / findUniqueDo not treat uniqueness as authorization; validate Provider ownership separately.
update / deleteInclude Provider ownership in the lookup before mutation.
includeAvoid loading large related graphs without a clear need.
selectPrefer minimum necessary field selection for PHI-sensitive operations.
transactionUse $transaction for dependent writes and sequence updates.

Generation Command

cd C:\TruecareSystem\API
pnpm prisma generate