## Background We use Prisma exclusively to manage our database schema and migrations. All changes to the database go through Prisma. This document explains how to run a migration. ## Running a migration to Dev Database 1. Make sure you have the latest version of the codebase. And make sure you don't have any uncommitted migration files. 2. Run the following command on the dev db to generate a migration: ```bash DATABASE_URL="dev_postgres_connection_string" npx prisma migrate dev --name ``` If this runs successfully, you will see a new migration file in the `prisma/migrations` directory. ## Running a migration to Prod Database 1. If the above step successfully completes, run the following command to apply the migration to the production database: 2. The command below instantly applies the schema changes to the production database, so BE SURE IT WON'T BREAK PRODUCTION. ```bash DATABASE_URL="prod_postgres_connection_string" npx prisma migrate deploy ```