anyone have experience with bidirectional relation...
# random
t
anyone have experience with bidirectional relations using the
@relation
tag I’m having trouble getting it to work.
Copy code
type User {
    id: ID! @unique
    bookings: [Booking!]! @relation(name: "BookingsByUser")
    createdBookings: [Booking!]! @relation(name: "BookingsCreatedByUser")
}

type Booking {
    id: ID! @unique
    user: User! @relation(name: "BookingsByUser")
    orignalUser: User @relation(name: "BookingsCreatedByUser")
}
This throws an error on deployment
ERROR: There is a relation ambiguity during the migration. Please first name the old relation on your schema. The ambiguity is on a relation between Booking and User. Please name relations or change the schema in steps.
m
That error comes up because you added a new relation and at the same time you started to name them. Your data model looked something probably like this before. There is no ambiguity.
Copy code
type User {
    id: ID! @unique
    bookings: [Booking!]!
}

type Booking {
    id: ID! @unique
    user: User!
The error message suggests to do this now as an intermediate step. This will inform Prisma about the name you want to use from now on for this relation.
Copy code
type User {
    id: ID! @unique
    bookings: [Booking!]! @relation(name: "BookingsByUser")
}

type Booking {
    id: ID! @unique
    user: User! @relation(name: "BookingsByUser")
}
Afterwards you can deploy your final schema correctly.