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
The Issue is when you reference a foreign key to a table, for example- User and Chat
the generated schema with error is given below
model User {
id Int @id@unique@default(autoincrement())
Username String @unique
}
model Chat {
id String @id@unique@default(uuid())
createdOn DateTime @default(now())
MadeBy User
Content String
}
as you can see the Madeby in Chat Model will throw an error as no field was specified for reference, and in the User Model, The Chats were not reverse referenced,
see the code with no error is given below,
model User {
id Int @id@unique@default(autoincrement())
Username String @unique
Chat Chat[]
}
model Chat {
id String @id@unique@default(uuid())
createdOn DateTime @default(now())
MadeBy Player @relation(fields: [id], references: [Username])
Content String
}
The text was updated successfully, but these errors were encountered:
The Issue is when you reference a foreign key to a table, for example- User and Chat
the generated schema with error is given below
model User {
id Int @id @unique @default(autoincrement())
Username String @unique
}
model Chat {
id String @id @unique @default(uuid())
createdOn DateTime @default(now())
MadeBy User
Content String
}
as you can see the Madeby in Chat Model will throw an error as no field was specified for reference, and in the User Model, The Chats were not reverse referenced,
see the code with no error is given below,
model User {
id Int @id @unique @default(autoincrement())
Username String @unique
Chat Chat[]
}
model Chat {
id String @id @unique @default(uuid())
createdOn DateTime @default(now())
MadeBy Player @relation(fields: [id], references: [Username])
Content String
}
The text was updated successfully, but these errors were encountered: