Join Slack
Powered by
Can i use uuid() for primary key? What if a collis...
# orm-help
h
Halvor
08/19/2021, 1:17 PM
Can i use uuid() for primary key? What if a collision occurs? Does prisma detect that and retries?
r
Ryan
08/19/2021, 1:23 PM
Yes you can. There will never be a collision when using UUID’s that Prisma generates.
h
Halvor
08/19/2021, 1:25 PM
How does prisma acheive that? Does it generate and check if it is unique in db? And redraws a new uuid if it collides?
d
dpetrick
08/19/2021, 1:32 PM
Prisma uses uuid v4, collisions are exceptionally rare. If you’d ever get one, you’d see a unique constraint violation error. Prisma doesn’t retry.
h
Halvor
08/19/2021, 1:38 PM
Ok, so to be sure i should catch that error and retry then?
r
Ryan
08/19/2021, 1:39 PM
You will never get a collision even if you have more than 10 million records.
h
Halvor
08/19/2021, 1:42 PM
Ok thx.
18
Views
Open in Slack
Previous
Next