Prisma Migrate is amazing, it helps you manage your database and generates typings for your database schema automatic.
However you can still make mistakes that takes down your app, so here is the rules:
You can not add and delete columns in same release
If you add columns, migrate first and deploy.
When deployed to production, Prisma will try to select the column and if you did not migrate first the column will not exist and your code will fail.
If you delete columns, deploy first and migrate.
If you migrate first, the column will disappear in production and your old code still expects to find the column. Therefore deploy first so the code does not try to select the column, the migrate to remove the column.
You can not rename columns in the same release
You have to do it in three steps if you want to do without downtime.
Say to need to rename “cur” to “currency”.
If you do that in one deploy, you can not do that without taking your database offline and migrating. If not you code will try to select either the new or old column and it is impossible to deploy and migrate in the same second.
So to rename 3 deploys:
Create the new column, so you have both “cur” and “currency”.
Change the code to write to both columns.
Delete old column.