notiz-dev / prisma-dbml-generator

Prisma DBML Generator
MIT License
685 stars 37 forks source link

Issues with multiple foreign keys pointing the same table #11

Closed melissafzhang closed 3 years ago

melissafzhang commented 3 years ago

I have this schema where there are multiple foreign keys pointing at User. When running npx prisma generate I get the error Did not find a relation for model User and field referralUser. Is this use case supported?

"prisma": "2.21.2"
"prisma-dbml-generator": "^0.5.0"
model User {
  id                            Int                      @default(autoincrement()) @id
  createdAt                     DateTime                 @default(now())
  updatedAt                     DateTime                 @updatedAt
  referralReferrer              Referral[]               @relation("referrer")
  referralUser                  Referral[]               @relation("user")
 }

model Referral {
  id           Int          @default(autoincrement()) @id
  referrerId   Int
  referrer     User         @relation("referrer", fields: [referrerId], references: [id])
  referralCode String
  userId       Int
  user         User         @relation("user", fields: [userId], references: [id])
}
melissafzhang commented 3 years ago

Actually the error I'm getting now is TypeError: models.map(...).flat is not a function which happens even with just one model