adding required fields to a prisma table while having data
This is probably a very common issue you might've been facing.
Let's say I've a table user in prisma
Now this is the table i have on prod. Later on , i want to add email field and it want it to be required. But if i try to migrate that , prisma will ask me to reset the db.
Is there any workaround this , without having to make the email field optional?
4 Replies
Not really - Prisma is entirely correct. If you really want to do it then 1. Add it as an optional field, 2. Fill in values for existing rows in some way, 3. Make it required now that every row has a value
So if i migrate it as optional , then add values to all the existing rows and change it to required , prisma will allow that?
Should do
Hey @Pluto can you give feedback if it worked? 😄 I'm quite curious : )