Solve migration conflicts

This is a complete noob question, but I'm new to db management and migration in general, and I can't find what I'm looking for in the prisma docs: https://www.prisma.io/docs/concepts/components/prisma-migrate Over time my prisma.schema changes. I want to migrate my existing data. If there is a new field being added to a table, it's no big deal as long as it's nullable or has a default value set in the schema. But if I want to make it required or do something else that requires manual explanation on how to do things, how do I tell prisma? What's the flow there? For now I usually fiddle a bit around locally using prisma db push and resetting my local db a few times until I get what I want, and finally use prisma migrate dev to create the migration file. But this of course has no logic for existing data included (which is needed for prod env later on). Do I just edit that migration file and manually add SQL statements to it to fill the new data fields, or what's the way to go there?
Prisma
Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
3 Replies
Krish12003
Krish120033y ago
but yes, you have full control over the migrations by editing the migration sql files
Froxx
FroxxOP3y ago
I see, so I guessed correctly. Thanks for the link. It seems, I haven't looked for the right terms. Is there also a plugin or so for prisma that auto detects these kind of conflicts and suggests solutions to them? Like when I add a new string-typed field, it asks me for a default value for existing records or so? I have a friend using Django and he says that's the way it works there normally and he pretty much never has to write sql by himself for migrations. My sql skills are pretty poor, that's why I'm asking
Want results from more Discord servers?
Add your server