Skip to main content

Database Migrations

4. Database Migrations

Prisma’s migration system was used to synchronize our schema changes with the database. Each time we modify schema.prisma, we create and apply a migration.

Creating a Migration

To apply schema changes, we use:

npx prisma migrate dev --name <migration_name>

This command generates a new migration file containing SQL commands to implement the changes in the database.

Migrations in Production

In production, the npx prisma migrate deploy command is used to apply all pending migrations in one step, ensuring the database schema is up to date.