They serve two different environments. The prisma db push is not to be used in your production environment, as stated in the docs

db push uses the same engine as Prisma Migrate to synchronize your Prisma schema with your database schema, and is best suited for schema prototyping. The db push command:

  1. Introspects the database to infer and executes the changes required to make your database schema reflect the state of your Prisma schema.

  2. By default, after changes have been applied to the database schema, generators are triggered (for example, Prisma Client). You do not need to manually invoke prisma generate.

  3. If db push anticipates that the changes could result in data loss, it will:

  • Throw an error
  • Require the --accept-data-loss option if you still want to make the changes

Note: db push does not interact with or rely on migrations. The migrations table will not be updated, and no migration files will be generated.

The prisma migrate dev is used in you local environment, as explained in the docs

migrate dev is a development command and should never be used in a production environment.

This command:

  1. Replays the existing migration history in the shadow database in order to detect schema drift (edited or deleted migration file, or a manual changes to the database schema)
  2. Applies pending migrations to the shadow database (for example, new migrations created by colleagues)
  3. Generates a new migration from any changes you made to the Prisma schema before running migrate dev
  4. Applies all unapplied migrations to the development database and updates the _prisma_migrations table
  5. Triggers the generation of artifacts (for example, the Prisma Client)

The migrate dev command will prompt you to reset the database in the following scenarios:

  • Migration history conflicts caused by modified or missing migrations
  • The database schema has drifted away from the end-state of the migration history

If you have any other question regarding this, there is this comparison in the docs explaining when to use one or the other.

Answer from Daniel Olavio Ferreira on Stack Overflow
Top answer
1 of 4
19

They serve two different environments. The prisma db push is not to be used in your production environment, as stated in the docs

db push uses the same engine as Prisma Migrate to synchronize your Prisma schema with your database schema, and is best suited for schema prototyping. The db push command:

  1. Introspects the database to infer and executes the changes required to make your database schema reflect the state of your Prisma schema.

  2. By default, after changes have been applied to the database schema, generators are triggered (for example, Prisma Client). You do not need to manually invoke prisma generate.

  3. If db push anticipates that the changes could result in data loss, it will:

  • Throw an error
  • Require the --accept-data-loss option if you still want to make the changes

Note: db push does not interact with or rely on migrations. The migrations table will not be updated, and no migration files will be generated.

The prisma migrate dev is used in you local environment, as explained in the docs

migrate dev is a development command and should never be used in a production environment.

This command:

  1. Replays the existing migration history in the shadow database in order to detect schema drift (edited or deleted migration file, or a manual changes to the database schema)
  2. Applies pending migrations to the shadow database (for example, new migrations created by colleagues)
  3. Generates a new migration from any changes you made to the Prisma schema before running migrate dev
  4. Applies all unapplied migrations to the development database and updates the _prisma_migrations table
  5. Triggers the generation of artifacts (for example, the Prisma Client)

The migrate dev command will prompt you to reset the database in the following scenarios:

  • Migration history conflicts caused by modified or missing migrations
  • The database schema has drifted away from the end-state of the migration history

If you have any other question regarding this, there is this comparison in the docs explaining when to use one or the other.

2 of 4
11
  • Prisma db push syncs (and formats) your prisma schema to that of your database schema.
  • While prisma migrate dev "command automatically generates SQL migration files (saved in /prisma/migrations) and applies them to the database".

The main difference between both is the generation of the migration files.

🌐
Prisma
prisma.io › home › prototyping your schema › prototyping your schema › prototyping your schema › prototyping your schema
Prototyping your schema | Prisma Documentation
The migrations table _prisma_migrations will not be created or updated, and no migration files will be generated. When working with PlanetScale, we recommend that you use db push instead of migrate.
Discussions

I ran `prisma db push`, and now when I run `prisma migrate dev` it prompts me to reset the database. How do I migrate without resetting and losing the data?
I ran `prisma db push`, and now when I run `prisma migrate dev` it prompts me to reset the database. How do I migrate without resetting and losing the data? More on github.com
🌐 github.com
4
1
November 9, 2022
Correct pattern of Generating Migrations
I check on prisma studio, and indeed, there is no table. So, why is the table missing, if I have "run" the migration? In the docs it suggests that migrate is correct to use on CI, not db push. It also mentions that it will apply pending migrations. More on github.com
🌐 github.com
2
1
How do I use Prisma without having to wipe my database all the time?
Think of it like this: You have a table with some users, none of which have a last name. Now you update schema.prisma with a required column called lastName, without a default value. How should Prisma handle the migration for you? Since Prisma can't guess the last name of every user, the only reasonable thing it can do is to ask you to recreate the data—which means resetting that table. To work around that, you need two migrations. You first set the column's default value to a placeholder—ensuring every row has a value. You then make a second migration where you remove the default value. This is, of course, just one of many reasons for why Prisma would want to reset a table, or sometimes even the whole database (if the effect is large enough). Prisma migrations are great, and they make life so much easier! But you still need to consider how they are applied and design your database accordingly: Prisma won't be able to magically solve the logical impossibilities that may occur otherwise. So, just like with everything else in programming, you need to be careful and considerate, and the more you practice; the easier it gets. I think Prisma sometimes overpromises on "making database design easy". It sure makes it easier, but you still need to think about what's going on behind the scenes. The way it abstracts the database design behind a neat little schema—together with its automatic migrations—can sometimes make you miss the forest for all the trees. More on reddit.com
🌐 r/node
39
34
December 5, 2023
What's difference between prisma db push and prisma db migrate
Why does t3 have the command prisma db push when you can have prisma migrate or prisma migrate dev? TTCTheo's Typesafe Cult / questions3y ago · What's the difference between React.ComponentProps and React.PropsWithChildren ? More on answeroverflow.com
🌐 answeroverflow.com
March 16, 2023
🌐
Prisma
prisma.io › home › push › push › push
prisma db push | Apply Schema to Database (No Migrations) | Prisma Documentation
Push Prisma schema changes directly to the database with prisma db push. Ideal for prototyping and local dev. No migration history required.
Top answer
1 of 1
6

Hello @lumenwrites

npx prisma db push is meant for development use only. The development db is considered "resettable" and "seedable" as its used to develop your migrations and to test/tweak them if needed. Looks like you have used it in your production environment. In production, you should use npx prisma migrate deploy and it would ensure your db won't get reset in any case.

Now in order to resolve your current situation we need to tweak the migrations history using some primitives which migrate provides like the diff command(https://www.prisma.io/docs/reference/api-reference/command-reference#migrate-diff)

  1. You will need to generate a new migration which will be the difference between migrations history stored in your disk in the migrations folder and your production database. The --to-schema-datasource flag here point to the database stored in your .env file but you can also change this flag to --to-url if you prefer to give the database url in the command itself.
mkdir -p prisma/migrations/add-comments-and-post/
npx prisma migrate diff --from-migrations prisma/migrations --to-schema-datasource prisma/schema.prisma --shadow-database-url   --script >  prisma/migrations/add-comments-and-post/migration.sql

The --shadow-database-url parameter is required and you will need to point it to any empty postgres database either a local one or hosted one. Prisma will use that to reply migration history and calculate the diff.

This will create a new migration in prisma/migrations/add-comments-and-post/migration.sql which will have the SQL for the model you have added via db push.

  1. Now you have the migration ready, we will need to mark it as applied. This is because those tables already exists in the database and we can't run the actual CREATE sql statements to the database. We will just mark the migration as applied as it was already applied when you ran npx prisma db push.
npx prisma migrate resolve --applied add-comments-and-post
  1. Now, you should be ready to go. Run npx prisma migrate dev once now and it should say everything is in sync.
🌐
PlanetScale
planetscale.com › guides › frameworks and orms › prisma › automatic prisma migrations
Automatic Prisma migrations - PlanetScale
1 week ago - We recommend prisma db push over prisma migrate dev for the following reasons: PlanetScale provides Online Schema Changes that are deployed automatically when you merge a deploy request and prevents blocking schema changes that can lead to downtime.
🌐
Prisma
prisma.io › home › understanding migrations › understanding migrations › understanding migrations › understanding migrations
A mental model for Prisma Migrate | Prisma Documentation
Moves your database schema forward ... using prisma db execute command. The prisma db push command allows you to sync your Prisma schema and database schema without persisting a migration (/prisma/migrations)....
Find elsewhere
🌐
HatchJS
hatchjs.com › home › prisma db push vs migrate: which one should you use?
Prisma DB Push vs Migrate: Which One Should You Use?
December 25, 2023 - If you need a more powerful tool that allows you to track and manage changes to your database schema, then Prisma DB Migrate is a better choice. In the next section, we’ll take a closer look at each tool and we’ll discuss the factors you ...
🌐
Prisma
prisma.io › home › overview of prisma migrate › overview of prisma migrate
Prisma Migrate: Database, Schema, SQL Migration Tool | Prisma Documentation
Prisma Migrate hence provides the flexibility of an imperative migration tool by enabling you to modify what and how migrations are executed (and allows you to run custom SQL to e.g. make use of native database feature, perform data migrations, ...). If you are prototyping, consider using the db push command - see Schema prototyping with db push for examples.
🌐
Epic Web Dev
epicweb.dev › workshops › data-modeling-deep-dive › data-migrations › intro-to-data-migrations
Intro to Data Migrations | Epic Web Dev
September 28, 2023 - 00:00 Let's talk about migrations. So making changes so far, what we've done is we just ran npx prisma db push. And that just says whatever the database is right now, the schema is going to like be pushed up to the database. And that works okay for non-breaking changes.
🌐
GitHub
github.com › prisma › prisma › discussions › 25712
Using push + migrate messed up my db. Am I using them correctly and how to fix it? · prisma/prisma · Discussion #25712
The recommended workflow for prototyping changes before creating a migration is: a) Use prisma db push to quickly prototype and iterate on your schema changes. b) Once you're satisfied with the changes, run prisma migrate dev to generate a migration ...
Author   prisma
🌐
Ruheni
ruheni.dev › writing › migrate-diff-1
Building Prisma Migrate using Prisma Migrate — Schema Prototyping and Migrations
June 8, 2023 - When working with migration tools, such as Prisma Migrate, it is essential to define a source of truth that defines what the final state of the database should be. As for Prisma, the source of truth of the database schema structure is the Prisma schema. When you update your Prisma schema by adding/ deleting/ updating a field , naturally, your database schema falls behind. In order to sync your database schema with the Prisma schema, you would either run prisma db push or prisma migrate dev.
🌐
Epicweb
data.epicweb.dev › 03
03. Data Migrations
The short answer is you use push when you're experimenting with schema changes and migrate when you're ready to commit to a schema change. The longer answer is: Read the Prisma docs about it 😇
🌐
Reddit
reddit.com › r/node › how do i use prisma without having to wipe my database all the time?
r/node on Reddit: How do I use Prisma without having to wipe my database all the time?
December 5, 2023 -

I'm using Prisma for a large project I've been working on for the past few months, and I still don't understand the flow of it. At first I was migrating every time I made a change to my schema, and constantly getting the "All data will be lost" prompt. Since then I've learned to use `db push` while developing and then migrate when a feature is finished, but it's still constantly making me reset my database.

Right now I'm using the same db for dev and staging (because I don't want to pay for 2 different ones) but I'd imagine this would still be an issue if I had separate databases. What do I need to do to stop being forced to reset my db? Or, at least, how would I migrate my development db to mirror my production db without it being wiped?

As you can probably tell, this is my first time working with Prisma (or any ORM, in depth) so this might be a stupid question, but I can't find much online besides general tutorials. Any help would be greatly appreciated!

Top answer
1 of 5
23
Think of it like this: You have a table with some users, none of which have a last name. Now you update schema.prisma with a required column called lastName, without a default value. How should Prisma handle the migration for you? Since Prisma can't guess the last name of every user, the only reasonable thing it can do is to ask you to recreate the data—which means resetting that table. To work around that, you need two migrations. You first set the column's default value to a placeholder—ensuring every row has a value. You then make a second migration where you remove the default value. This is, of course, just one of many reasons for why Prisma would want to reset a table, or sometimes even the whole database (if the effect is large enough). Prisma migrations are great, and they make life so much easier! But you still need to consider how they are applied and design your database accordingly: Prisma won't be able to magically solve the logical impossibilities that may occur otherwise. So, just like with everything else in programming, you need to be careful and considerate, and the more you practice; the easier it gets. I think Prisma sometimes overpromises on "making database design easy". It sure makes it easier, but you still need to think about what's going on behind the scenes. The way it abstracts the database design behind a neat little schema—together with its automatic migrations—can sometimes make you miss the forest for all the trees.
2 of 5
19
bruh
🌐
Prisma ORM
mintlify.wiki › mintlify atlas › mintlify-atlas/docs-atlas-035637da › schema prototyping with db push
Schema Prototyping with db push - Prisma ORM
March 1, 2026 - Schema validation: Test schema changes before creating migrations · db push is for development only. Use prisma migrate for production databases.
🌐
Answer Overflow
answeroverflow.com › m › 1085907987144646768
What's difference between prisma db push and ...
March 16, 2023 - Why does t3 have the command prisma db push when you can have prisma migrate or prisma migrate dev? TTCTheo's Typesafe Cult / questions3y ago · What's the difference between React.ComponentProps and React.PropsWithChildren ?
🌐
Prisma
prisma.io › home › overview on prisma migrate › overview on prisma migrate › overview on prisma migrate › overview on prisma migrate › overview on prisma migrate
Overview on Prisma Migrate | Prisma Documentation
Prisma Migrate hence provides the flexibility of an imperative migration tool by enabling you to modify what and how migrations are executed (and allows you to run custom SQL to e.g. make use of native database feature, perform data migrations, ...). If you are prototyping, consider using the db push command - see Schema prototyping with db push for examples.
🌐
Answer Overflow
answeroverflow.com › m › 1342875401642311801
Switch to migrations after db push - Prisma
February 22, 2025 - Hello , I got a new project from a client , and they are using SQLite , I noticed they do not have any migrations , but rather db push directly , as this is not safe , I want to switch them to migrations , however how can we manage that without losing data as firing the migration will issue a drift
🌐
Reddit
reddit.com › r/node › where do you actually run prisma migrate deploy?
r/node on Reddit: Where do you actually run prisma migrate deploy?
December 11, 2022 -

I'm working on a little project with supabase and prisma, I've just been using one dev database which I update with prisma migrate dev. For production migrations, you're supposed to use prisma migrate deploy, which the prisma docs say to put in a CI/CD pipeline.

  • I don't have a CI/CD pipeline

  • I can't run it locally from my project directory, cause prisma uses the DATABASE_URL environment, which is pointing to my dev database

So I'm wondering where y'all would actually run prisma migrate deploy from? Should I just bite the bullet and learn some github actions? Or is there an easier way?

EDIT: The prisma docs recommend using dotenv-cli to use switch between .env files, but I'm kinda worried that I might fuck up somehow and end up running prisma migrate reset on my prod database, and delete everything. But, seems like that might be my plan until I figure out some CI/CD stuff.

Still definitely open to any advice though!