When I'm trying to create event in calendar this error throws:
Invalid `prisma.dayEvent.create()` invocation:
Null constraint violation on the fields: (`id`)
Which is weird cause id have default() in prisma schema
Prisma schema:
model dayEvent {
id String @id @default(cuid())
name String
date DateTime
calendar Calendar @relation(fields: [id], references: [id])
calendarId String
}
TRPC code where is prisma.create() triggering error:
create: protectedProcedure
.input(
z.object({ name: z.string(), date: z.date(), calendarId: z.string() })
)
.mutation(async ({ ctx, input }) => {
return ctx.prisma.dayEvent.create({ //Error here
data: {
name: input.name,
date: input.date,
calendarId: input.calendarId,
},
})
}),
Using full t3 stack
I searched on the web, but didn't find anything helpful.
Did npx prisma db push
to make sure database is in sync with the Prisma schema.