prisma/schema.prisma is the single source of truth —
not a migration file, not a diagram, not a document.
Model conventions
The migration workflow
Development usesdb push for speed; staging and production use
prisma migrate deploy, which only applies migration files. Both schema.prisma and
a migration file must be committed for every schema change.
1
Edit the schema
prisma/schema.prisma.2
Sync your local database
3
Develop and test against it
4
Generate the migration before committing
5
Review the generated SQL
In
prisma/migrations/<timestamp>_describe_your_change/migration.sql.6
Split enum additions
If the migration contains
ALTER TYPE … ADD VALUE, put the enum change in its own
preceding migration. PostgreSQL will not let a new enum value be used in the same
transaction that adds it.7
Check for duplicates
If the column or table already exists in a prior migration, do not create a second
one. Look in
prisma/migrations/ first.8
Commit both
Transactions
Conditional logic requires the interactive callback form:Never do these
Encryption coverage
A CI guard checks that fields holding credentials, tokens or secrets go through the application-layer encryption utilities. A field storing a raw token asString? fails
the guard unless it is explicitly approved and documented as a known limitation with a
follow-up ticket.
The guards
All of them run in
npm run check:all, which the quality gate
runs.