how can make a changes prisma.schema model fields, without losing data after mgration?

Viewed 74

How can make a change to the database with Prisma.js without having to reset the whole thing?

When I changed prisma.schema and run:

npx prisma migrate dev --name change-name

My database lost all data. Can I run another command which doesn't remove my data? What is best for me in this situation?

1 Answers

You would need to Baseline your database in order to not reset your database.

For the cases which contains data that must be maintained (like production), which means that the database cannot be reset, In those cases Baselining tells Prisma Migrate to assume that one or more migrations have already been applied. This prevents generated migrations from failing when they try to create tables and fields that already exist.

Related