Prisma migrations you can actually review in a pull request

Generate Prisma migrations as SQL in development, commit the files, and apply them in deploy with prisma migrate deploy. Do not push schema changes straight to production.

A schema change that only exists in someone's local database is a surprise waiting for production. With Prisma Migrate, the habit I want is simple: generate SQL in development, commit those files, review them in the pull request, and apply them in deploy with `prisma migrate deploy`.

I use Prisma on a TypeScript API that talks to Postgres. I wrote a longer [comparison with Drizzle](/journal/prisma-vs-drizzle-choosing-a-typescript-orm-for-postgres) if you are still choosing an ORM. This post is about the migration workflow I actually use on Prisma 6.

The two commands that matter

In development, after you change `schema.prisma`:

pnpm prisma migrate dev --name add_article_date_to_journal

That diffs the schema against the database, writes a SQL file under `prisma/migrations/`, applies it locally, and regenerates the client. The name should say what changed. `init2` is how you get a folder nobody wants to open later.

In deploy, against the production database:

pnpm prisma migrate deploy

That applies pending migration files. It does not invent new ones. It should be a step in the release, before the new app starts reading columns that do not exist yet, or after a backward-compatible expand if you are doing the change in two steps.

Do not use `prisma db push` on production. That path is for prototyping, when you are fine with the database being rebuilt. It is not a release tool.

What I look at in the pull request

The SQL file is the review, not only the `schema.prisma` diff. I read it for:

  • A `DROP` I did not mean, or a column rename that will go out as drop-and-add.
  • A new non-null column without a default, which will fail on a table that already has rows.
  • Indexes and constraints that will lock a busy table for too long.
  • Data backfills hidden inside the same migration as a structural change.

If the SQL is dangerous, I change the migration before it lands, not after it has been applied somewhere shared. Prisma's shadow-database checks catch some drift in development. They do not catch a migration that is technically valid and still a bad idea on a large table.

Expanding before you tighten

When I need to make a column required, or rename something an old app is still writing, I split the work. First I add the new shape and keep the old one working. Then I ship the app that uses the new shape. Then I remove the old one. That is slower than a single "just change the schema" commit, and it is the difference between a migration you can roll forward and a release you cannot.

Keep generate in the build

`prisma generate` has to run in CI and in the release build. Forgetting that is a classic Prisma footgun: the schema changed, the client did not, and the typecheck you ran locally already had a fresh client. I wire generate into the install or the build so a clean machine cannot skip it.

The goal is not a perfect ORM. The goal is a SQL file a reviewer can read, a deploy command that only applies what was reviewed, and no schema changes that exist only on one laptop.

Back to Journal