Prisma Migrations: local, dev and prod
Hi all,
I have a specific question on Prisma migrations with next.js and Vercel. For my project I have 3 postgresQL database versions:
- Local composed with docker
- Dev/preview hosted on Vercel
- Prod hosted on Vercel
There are two pipelines that Vercel runs when linked to my github repo - one to deploy to a preview environment when a PR is opened and one to deploy to prod when a PR is merged to main.
I want to make sure any migrations and database changes are tested first in the preview database, and then (if ok) can be applied to the prod database when the PR is merged with main.
My question is: what is the process with this setup? Is this advisable? And if so, how should I change my package.json scripts? Currently I just run
prisma migrate deploy
post install and prisma generate && next build
when running build.
To summarise, I think my ideal scenario would be (but this could be wrong and please tell me if it is):
1) When making changes to schema before PR, developer creates migration files then commits these along with PR
2) When PR is opened, pipeline runs to deploy to preview env and runs migration files on the preview db
3) When PR is approved and merged, pipeline runs to deploy to prod env and runs migration files on prod db
4) When a developer pulls main, they also run the new migration files from main on their local db0 Replies