fix: Ensure unique username in an organization (#15730)
This commit is contained in:
@@ -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");
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user