-
-
Notifications
You must be signed in to change notification settings - Fork 127
Closed as duplicate of#1992
Closed as duplicate of#1992
Copy link
Description
On postgres, logical prisma schema generation fails when a base field is used as part of a composite unique constraint.
model User {
id Int @id @default(autoincrement())
contentUserLikes ContentUserLikes[]
@@allow('all', true)
}
model Content {
id Int @id @default(autoincrement())
contentType String
contentUserLikes ContentUserLikes[]
@@delegate(contentType)
@@allow('all', true)
}
model Post extends Content {
title String
}
model Video extends Content {
name String
duration Int
}
model ContentUserLikes {
id Int @id @default(autoincrement())
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Restrict)
contentId Int
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade, onUpdate: Restrict)
@@unique([userId, contentId])
}This fails with the following error
- Generating PrismaClient enhancer
Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Error parsing attribute "@@unique": The given constraint name `ContentUserLikes_userId_delegate_aux_ContentUserLikes_conte_key` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> logical-1740247636262.prisma:59
|
58 | @@unique([userId, contentId])
59 | @@unique([userId, delegate_aux_ContentUserLikes_contentI_0])
|
error: Error parsing attribute "@@unique": The given constraint name `ContentUserLikes_userId_delegate_aux_ContentUserLikes_conte_key` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> logical-1740247636262.prisma:60
|
59 | @@unique([userId, delegate_aux_ContentUserLikes_contentI_0])
60 | @@unique([userId, delegate_aux_ContentUserLikes_contentI_1])
|
Validation Error Count: 2
[Context: getDmmf]
Prisma CLI Version : 6.3.1
✖ Generating PrismaClient enhancer
Prisma Enhancer: Failed to run "prisma generate" on logical schema: /tmp/tmp-3519865-AAekSeu95bZ9/logical-1740247636262.prisma
Metadata
Metadata
Assignees
Labels
No labels