If you want an easy way to develop, I can recommend Planetscale which has a very generous free tier. It's a mysql db service that has branches like your code. That means you can develop code locally, run prisma db push and then merge the dev branch of your db into prod when you want. Answer from Deleted User on reddit.com
🌐
Prisma
prisma.io › home › deploying database changes with prisma migrate › deploying database changes with prisma migrate › deploying database changes with prisma migrate › deploying database changes with prisma migrate
Deploying database changes with Prisma Migrate | Prisma Documentation
Here is an example action that will run your migrations against your database: ... name: Deploy on: push: paths: - prisma/migrations/** branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 - name: Install dependencies run: npm install - name: Apply all pending migrations to the database run: npx prisma migrate deploy env: DATABASE_URL: ${{ secrets.DATABASE_URL }}
🌐
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!

Discussions

Difference between prisma db push and prisma migrate dev - Stack Overflow
This is dangerously incorrect. prisma db push is never used against a production environment. As stated in the docs it is for local rapid prototyping only. All operations against production environments should be performed by deploying migrations. More on stackoverflow.com
🌐 stackoverflow.com
node.js - Should I run prisma migrate on every app start? - Stack Overflow
In this case, I would suggest running prisma migrate deploy as mentioned here in your CI/CD step before deploying the application so that you do not need to perform it on every start script which is not ideal in this case. More on stackoverflow.com
🌐 stackoverflow.com
Issues with Prisma migrations
I accidentally created a failing migration using Prisma which actually worked on my development but failed in prod, I fixed the migration and deployed again but now I get this error: migrate found failed migrations in the target database, new migrations will not be applied. More on community.fly.io
🌐 community.fly.io
18
0
November 29, 2023
Issue Deploying Next.js / Prisma app
Hello everyone, I’ve been trying for a few hours to deploy my Next.js / prisma application. With the generated Dockerfile and fly.toml The build deployment was successful, however my database is not properly connected to my web application. I created a separate fly postgres database and connected ... More on community.fly.io
🌐 community.fly.io
13
0
August 15, 2023
🌐
GitHub
github.com › prisma › prisma › discussions › 24571
How should migration be done to Production? · prisma/prisma · Discussion #24571
The SQL migration files located in the prisma/migrations directory. These files represent the history of changes made to your database schema. The prisma migrate deploy command applies all pending migrations found in this directory.
Author   prisma
🌐
Prisma
prisma.io › home › deploy › deploy › deploy
prisma migrate deploy | Apply Migrations to Production | Prisma Documentation
The prisma migrate deploy command applies all pending migrations and creates the database if it doesn't exist.
🌐
Kitemetric
kitemetric.com › blogs › mastering-prisma-migrations-dev-vs-deploy
Mastering Prisma Migrations: Dev vs. Deploy | Kite Metric
Master Prisma's database migration commands: `migrate dev` for local development and `migrate deploy` for production. Learn the key differences and best practices for safe and efficient schema management.
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.

Find elsewhere
🌐
Prisma
prisma.io › home › understanding migrations › understanding migrations › understanding migrations › understanding migrations
A mental model for Prisma Migrate | Prisma Documentation
The prisma migrate deploy command allows you to sync your migration history from your development environment with your database in your staging or production environment.
🌐
notiz
notiz.dev › blog › prisma-migrate-deploy-with-docker
Prisma Migrate: Deploy Migration with Docker
November 22, 2021 - First of all, one command is very important: COPY prisma ./prisma/. This makes sure to not only copy the schema.prisma into the Docker image, but also includes the migrations directory. This is necessary as prisma migrate deploy only executes the migration history files.
🌐
Prisma
prisma.io › home › deploy migrations from a local environment › deploy migrations from a local environment › deploy migrations from a local environment › deploy migrations from a local environment
Deploy migrations from a local environment | Prisma Documentation
If you do not have an automated CI/CD process, you can technically deploy new migrations from your local environment to production in the following ways: Make sure your migration history is up to date. You can do this through running prisma migrate dev, which will generate a migration history from the latest changes made.
🌐
Fly.io
community.fly.io › questions / help
Issues with Prisma migrations - Questions / Help - Fly.io
November 29, 2023 - I accidentally created a failing migration using Prisma which actually worked on my development but failed in prod, I fixed the migration and deployed again but now I get this error: migrate found failed migrations in t…
🌐
Fly.io
community.fly.io › javascript
Issue Deploying Next.js / Prisma app
August 15, 2023 - Hello everyone, I’ve been trying for a few hours to deploy my Next.js / prisma application. With the generated Dockerfile and fly.toml The build deployment was successful, however my database is not properly connected to my web application. I created a separate fly postgres database and connected the two with flyctl postgres attach.
🌐
Prisma
prisma.io › home › development and production › development and production › development and production › development and production
Development and production | Prisma Documentation
See: Team development with Prisma Migrate . In production and testing environments, use the migrate deploy command to apply migrations:
🌐
Stack Overflow
stackoverflow.com › questions › 79169078 › how-to-safely-deploy-and-migrate-a-postgresql-prisma-schema-to-a-production-data
amazon web services - How to Safely Deploy and Migrate a PostgreSQL Prisma Schema to a Production Database with Docker, EC2, and AWS RDS Without Downtime? - Stack Overflow
I am working on deploying the latest changes from our staging environment to our production environment. We’re using PostgreSQL with Prisma for database management, and our setup involves Docker containers running on an EC2 instance. Here’s a detailed overview of our architecture and workflow, along with some questions about the correct approach for running Prisma migration commands to avoid breaking the production environment.
🌐
Fig
fig.io › manual › prisma › migrate › deploy
prisma migrate deploy | Fig
Apply pending migrations to update the database schema in production/staging
🌐
YouTube
youtube.com › neon
Prisma essentials: from development to production (Prisma Migrate workflow) - YouTube
Learn about database migrations using Prisma Migrate and how to go from Development to Preview to Production.- Code example: https://github.com/neondatabase/...
Published   March 27, 2024
Views   2K
🌐
Prisma
prisma.io › home › deploy to render › deploy to render › deploy to render › deploy to render › deploy to render
Deploy a Prisma app to Render | Prisma Documentation
If you deployed your Render services using the Blueprint: In your render.yaml file, change the preDeployCommand to: npx prisma migrate deploy; npx prisma db seed
🌐
Prisma
prisma.io › migrate
Prisma Migrate | Database Migrations for Prisma ORM
While prototyping you can create ... the prisma db push command without creating migrations. Quickly seed your database with data by defining a seed script in JavaScript, TypeScript or Shell. Migrate detects database schema drift and assists you in resolving them. Migrate supports dedicated workflows for carrying out migrations safely in production. Migrate can be integrated into CI/CD pipelines, e.g. GitHub Actions, to automate applying migrations before deployment...
🌐
Prisma
prisma.io › home › getting started with prisma migrate › getting started with prisma migrate › getting started with prisma migrate
Getting started with Prisma Migrate | Prisma Documentation
Your Prisma schema is once again in sync with your database schema, and your migration history contains two migrations: migrations/ └─ 20210313140442_init/ └─ migration.sql └─ 20210313140442_added_job_title/ └─ migration.sql · Your migration history can be committed to version control and use to deploy changes to test environments and production.