1 to 1 relations get @unique applied.
See original GitHub issueI am having an issue with Prisma 1 to 1 relationships, prisma formats my relation with @unique which creates a unique constraint on the column. This makes it to where the field can only have 1 null in it. The opposite table is optional, I have set the relation with ? on them so that it reflects, but this @unique getting added prevents the data from saving after the first record is added to the system.
model Intake {
legalCase LegalCase? @relation("LegalCase_intake")
}
model LegalCase {
...
intakeId String?
intake Intake? @relation(name: "LegalCase_intake", fields: [intakeId], references: [id])
After I run prisma apply the intakeId looks like this …
intakeId String? @unique
intake Intake? @relation(name: "LegalCase_intake", fields: [intakeId], references: [id])
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
What Is a One-to-One Relationship in a Database? - Vertabelo
A one-to-one relationship in a database is relatively uncommon. Check out these examples of 1:1 relationships in the real world and find out ......
Read more >sql - How to implement one-to-one, one-to-many and many-to ...
In a one to one relationship, the join field should be unique in both tables. It is likely a PK on one table...
Read more >Configure One-to-One relationship in Code First Entity ...
A one-to-zero-or-one relationship happens when a primary key of one table becomes PK & FK in another table in a relational database such...
Read more >One-to-one relations - Prisma
One-to-one (1-1) relations refer to relations where at most one record can be connected on both sides of the relation. In the example...
Read more >One-To-One and Many-to-Many Database Relationships
Each row in the Students table has a unique Student ID, and Classes have a unique Class ID. Each line thus becomes defined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
legalCase: input.legalCase != null ? {} : undefined
I ended up patching my prisma call to check if the legal case is included in the call, and if not, dont send it through.What is the query you are executing? Can you turn on https://pris.ly/d/debugging and https://pris.ly/d/logging and post the output here?