You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiple Relations from a table to another are not correctly introspected #3915
I have a table called "Group". A "Group" has a Many-to-Many relation to "User" and also a field called authorId which has a foreign key to "User.id" (One-to-Many Relation). On introspecting I generates the schema file, but if I wanna use it, I always get the error "P2021 - The table _GroupToUserManyToMany does not exist in the current database.".
Here the schema of the product:
model Group {
id Int @id @default(autoincrement())
name String
authorId Int
author User @relation(fields: [authorId], references: [id])
users User[] @relation("GroupToUserManyToMany")
@@index([authorId], name: "authorId")
}
Activity
janpio commentedon Oct 14, 2020
Can you share the SQL of your database (preferably a minimized version) so we can try to reproduce this?
diegozuber commentedon Oct 14, 2020
@janpio of course:
pantharshit00 commentedon Nov 4, 2020
I can reproduce this. I think link table mapping needs to be fixed.
Reproduction steps:
mavilein commentedon Nov 4, 2020
That is probably a problem the handling of ambiguous relations in introspection. Naming both relations explicitly might help to work around this bug:
pantharshit00 commentedon May 4, 2021
This is still reproducible in
2.21.2. Adding the candidate label.larsniet commentedon Mar 31, 2022
It's still an issue in
3.11.1.larsniet commentedon Mar 31, 2022
Further explanation can be found in this issue. Weird how this bug has been around for so long.