Replies: 4 comments
-
What is the Prisma context of your question? What Prisma schema do you get when you introspect your database that has that behavior? (Aside: The SQL you are sharing does not show any foreign key, so does not match the ERD or the issue title) |
Beta Was this translation helpful? Give feedback.
-
thank you for response :)
|
Beta Was this translation helpful? Give feedback.
-
That is not a valid Prisma schema (for multiple reasons, we do not support Can you please clarify your issue or question? Thanks. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry. Since it was extracted from the project code and arranged, it may contain syntax errors. I will try to close the issue. model Areas {
id String @id
name String
weatherForecasts WeatherForecasts[]
}
model WeatherForecasts{
+ id String @id @default(cuid())
date String
areas Areas @relation(fields: [areasId], references: [id], onDelete: Cascade)
- areasId String @unique @map("areas_id")
+ areasId String @map("areas_id")
temperature Int
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updateAt @map("updated_at")
}
@@unique([date, areasId])
@@map("weather_forecasts") |
Beta Was this translation helpful? Give feedback.
-
Problem
When I set a composite key that includes FK as an ID, the ID violates the unique key.
Even if you create a composite key, a unique constraint is created on the FK, so duplicate FKs are not allowed.
I think it is possible to have a composite key like this in business.
Suggested solution
Ability to create a composite key of date and xxx_id
Alternatives
Additional context
Beta Was this translation helpful? Give feedback.
All reactions