Suhail
06/23/2020, 7:28 AMError Cannot return null for non-nullable type
. I added a new attribute name!
in the data model file and then did prisma generate
and prisma deploy
. When I query, it gives the above errorRyan
06/23/2020, 7:33 AMSuhail
06/23/2020, 7:44 AMtype User {id: ID! @id, username: string}
Then I did prisma generate
and then prisma deploy
I performed insertions and update queries using the API generated by prisma prisma.updateUser
Then I updated the data model file as
type User {id: ID! @id, username: string, name: string!}
adding name
attribute and making it !
.
Now when I perform prisma.user
(i.e. get query), I get this error @RyanRyan
06/23/2020, 7:47 AMname
. Due to this the previous records will have the name
field set to null
.
Could you try adding non-null values to name for all the current records in the database and then query again?Suhail
06/23/2020, 7:48 AMRyan
06/23/2020, 7:50 AMname: String
If you add a non-null field, then you would always need to update the previous records before performing the migrations.Suhail
06/23/2020, 7:53 AMprisma
to do automatic migrations?Ryan
06/23/2020, 7:55 AMSuhail
06/23/2020, 7:56 AMprisma deploy
?Ryan
06/23/2020, 8:02 AMname: String
and run prisma deploy
2. Seed the data via a script (either js/ts) file into all current records in the database
3. Change the field to non-nullable name: String!
and again run prisma deploy
Currently you would have to follow these steps to add a non-nullable field with already present recordsSuhail
06/23/2020, 8:04 AM