True Care SystemTrue Care SystemDocumentation
Return to Website

POSTGRESQL INTEGRITY

Database Standards

Protect tenant isolation, referential integrity, performance, and recoverability in PostgreSQL.

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.

Core Rules

TopicStandard
Provider ownershipProvider-owned tables must contain an indexed providerId where applicable.
Primary keysUse stable unique identifiers and never expose predictable identifiers as the only authorization control.
Foreign keysUse relations that preserve ownership and prevent orphaned records.
IndexesIndex Provider scope, frequently filtered dates, statuses, and relationship keys.
Effective datesUse explicit start and end dates for rates, authorizations, tax rules, and time-sensitive configuration.
Soft deletionPrefer deactivation or archived state where history must remain available.
TransactionsUse transactions for related writes that must succeed or fail together.

SQL Change Process

  1. Update schema.prisma.

    Define the final model and relations.

  2. Write and run manual SQL.

    Create or alter tables explicitly after review and backup.

  3. Run Prisma Generate.

    Refresh the generated client after the database structure matches the schema.

No Prisma migrations

True Care System database changes follow schema.prisma + manually reviewed SQL + Prisma Generate. Do not run Prisma migration commands.