To switch the unique constraint on the index when updating two items in Prisma:
await prisma.myModel.update({
where: { id: firstItemId },
data: { name: null },
})
await prisma.myModel.update({
where: { id: secondItemId },
data: { name: "newName" },
})
await prisma.myModel.update({
where: { id: firstItemId },
data: { name: "newFirstItemName" },
})
By doing this, you are effectively switching the unique constraints of the two items.
Asked: 2023-06-10 19:26:55 +0000
Seen: 20 times
Last updated: Jun 10 '23