Warm tip: This article is reproduced from stackoverflow.com, please click
prisma prisma-graphql prisma-binding

Prisma ORM how to create migration

发布于 2020-03-29 21:02:16

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 ??

Questioner
Loki
Viewed
20
realAlexBarge 2020-01-31 18:46

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/