fix: Ensure unique username in an organization (#15730)

This commit is contained in:
Hariom Balhara
2024-07-15 06:11:24 +00:00
committed by GitHub
parent 6d2ec71df3
commit 7b24972900
2 changed files with 12 additions and 0 deletions
@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[username,organizationId]` on the table `Profile` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Profile_username_organizationId_key" ON "Profile"("username", "organizationId");
+4
View File
@@ -349,7 +349,11 @@ model Profile {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// A user can have multiple profiles in different organizations
@@unique([userId, organizationId])
// Allow username reuse only across different organizations
@@unique([username, organizationId])
@@index([uid])
@@index([userId])
@@index([organizationId])