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
Cannot use @relation(id) to specify the side of the relation #185
// The @relation attribute can be used to specify the side of the foreign key.
// Here, it's explicitly stored on the `User` model.
model User {
id Int @id
customer Customer? @relation(id) // stores a foreign key
name String
}
model Customer {
id Int @id
user User?
address String
}
However, when trying it with the following schema:
datasource db {
provider = "sqlite"
url = "file:dev.db"
default = true
}
generator photon {
provider = "photonjs"
}
model B {
id String @default(cuid()) @id
a A? @relation(id, name: "BtoA")
c C? @relation(id, name: "BtoC")
}
model A {
id String @default(cuid()) @id
b B?
}
model C {
id String @default(cuid()) @id
b B?
}
And then opening the generated dev.db file and exporting its schema, we get the following:
datasource db {
provider ="sqlite"
url ="file:dev.db"default=true
}
generator photon {
provider ="photonjs"
}
model B {
id String@default(cuid()) @id
a A?@relation(references: [id], name: "BtoA")
c C?@relation(references: [id], name: "BtoC")
}
model A {
id String@default(cuid()) @id
b B?
}
model C {
id String@default(cuid()) @id
b B?
}
Thanks a lot for opening this issue @Errorname 🙌 I've just updated the example code on the Lift website and also clarified this in the actual documentation.
Activity
pantharshit00 commentedon Jul 19, 2019
You will need to do the following:
datasource db { provider = "sqlite" url = "file:dev.db" default = true } generator photon { provider = "photonjs" } model B { id String @default(cuid()) @id a A? @relation(references: [id], name: "BtoA") c C? @relation(references: [id], name: "BtoC") } model A { id String @default(cuid()) @id b B? } model C { id String @default(cuid()) @id b B? }Can you please share the link the to example?
Errorname commentedon Jul 19, 2019
Ah, thanks for the answer, so that means it's just an inconsistency between the documentation and the example.
The example can be found directly on the https://lift.prisma.io/ website, when clicking on the "One to One" button
nikolasburk commentedon Aug 26, 2019
Thanks a lot for opening this issue @Errorname 🙌 I've just updated the example code on the Lift website and also clarified this in the actual documentation.
DEPLOY_GITHUB_TOKEN, and the notification sits with the publish it re…