Skip to main content
PostgreSQL through Prisma. 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 uses db 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

CI verifies that migrations are in sync with the schema and blocks a PR with drift.
Never run prisma migrate dev without --create-only in Docker — it can drop your development database.

Transactions

Conditional logic requires the interactive callback form:
The batch array form evaluates its arguments before the transaction opens, so a condition depending on an earlier statement’s result is evaluated against stale data.

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 as String? 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.

Seeding

Demo seeding is reversible by design — it is used on real installations for training, so it has to come back out cleanly.