Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma schema: possible issue on connections unique constraint #3

Open
I-bangash opened this issue Apr 14, 2024 · 0 comments
Open

Prisma schema: possible issue on connections unique constraint #3

I-bangash opened this issue Apr 14, 2024 · 0 comments

Comments

@I-bangash
Copy link

I think the connection's unique constraint on 'type' might be missing a userId condition.

Issue:
Adding multiple connections of the same type fails, even if userId is different. For example: adding 2 discord connections from 2 different users causes unique constraint failure ( even when discord accounts and user accounts are different).

Possible fix:
Fixed on my side by adding userId condition to the unique constraint on type:

Old Connections schema:

model Connections {
  id               String          @id @default(uuid())
  type             String          @unique
// rest of the file
}

changed Connections schema:

model Connections {
  id               String          @id @default(uuid())
  type             String          
// rest of the file

  @@unique([userId, type])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant