Skip to content

Commit

Permalink
Add unique constraint on invitations to ensure no duplicate invitatio…
Browse files Browse the repository at this point in the history
…ns get created
  • Loading branch information
dsamojlenko committed Oct 22, 2024
1 parent 1456e64 commit 30e86d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[email,templateId]` on the table `Invitation` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Invitation_email_templateId_key" ON "Invitation"("email", "templateId");
2 changes: 2 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ model Invitation {
expires DateTime
templateId String
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@unique([email, templateId])
}

0 comments on commit 30e86d3

Please sign in to comment.