How to handle Prisma schema changes with PlanetScale
Feeling sooooo confused about what I thought should be a simple concept. I made a prisma schema change, just added a createdAt and updatedAt field to a model with the prisma
@default(now())
and @updatedAt
attributes. Then ran prisma db push
, then opened a deploy request on PlanetScale. PlanetScale said the deploy would be safe. Then tried to deploy and got an error that updatedAt is not nullable and has no default value. How can I fix this? Why did PlanetScale say the deploy would be safe if it didn't work? And what I some resources I can look at to learn more about this, because I'm sure I'll have more complex schema changes in the future.2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The
@updatedAt
attribute acts as a default value. When a record is created or updated Prisma will automatically update the field. However, when records exist already it doesn't add a default value. I'll see if I can use the @updatedAt
with a default value.
I know SQL constraints aren't a PlanetScale problem. The problem with PlanetScale is that it said it was safe to deploy when it wasn't.