Prisma ORM how to create migration

2.8k views Asked by At

I'm new to Prisma ORM, & I'm trying to make migrations in Prisma

I see that I way to do this is to update data.model & then just run:

 prisma deploy

But what if I want to create a migrations for specific versions of app how could I do that ??

1

There are 1 answers

0
realAlexBarge On BEST ANSWER

As the prisma documentation describes there are two ways of doing database migrations in prisma:

  1. Using the Prisma CLI
  2. Performing a manual DB migration with plain SQL

If you follow the first approach and edit your data model the changes will be carried out automagically once you run prisma deploy. You can specify the service and stage this will be rolled out to via the PRISMA_ENDPOINT environment variable:

PRISMA_ENDPOINT="http://localhost:4466/{SERVICE}/{STAGE}"

This way you can roll out and test you data model changes in a different stage or on a different service.

The second approach is to manually change the database model via plain SQL. Be careful to ensure the database schema and your data model are in sync.

For more information check out: https://www.prisma.io/docs/datamodel-and-migrations/migrations-POSTGRES-asd4/