There are multiple relations between "places" and "medias". Please specify relation name

Hello guys, could someone help me? I'm getting the following error: Error: There are multiple relations between "places" and "medias". Please specify relation name I have the following tables: https://gist.github.com/andrevandal/ad8494d375cb2277a6c2b0ee4a07ae60 As I don't have much experience with SQL, I'm not sure what I'm doing wrong.
Gist
tables.md
GitHub Gist: instantly share code, notes, and snippets.
3 Replies
Andrii Sherman
Sorry for a late response. As of 23th August 2023 we don't have this in docs, so that's totallu our fault inside one and many functions you have a fields called relationName that you can use to help drizzle understand a difference between relations that are looking into the same table Just a usage example for it
many(places, {relationName: 'custom_name'}),
many(places, {relationName: 'custom_name'}),
one(medias, { fields: [places.userId], references: [medias.id],relationName: 'custom_name' }),
one(medias, { fields: [places.userId], references: [medias.id],relationName: 'custom_name' }),
andrevandal
andrevandalOP2y ago
super, thank you!
monki boi
monki boi15mo ago
I have the same issue when running drizzle-kit studio even after adding relationNames to the relations

Did you find this page helpful?