P
Prisma•4mo ago
fwoelffel

Weak relations

Hi there, Is there any way to use Prisma relations without any foreign key constraint on Postgre? I'd like to be able to set this up on a per table basis and not for the whole database like relationMode = "prisma" would do. I've been looking online for this and it appears to be a feature that has been requested a couple years ago already. What's the status on this? Cheers
4 Replies
RaphaelEtim
RaphaelEtim•4mo ago
Hi @fwoelffel You may want to atake a look at using relationMode= "prisma as documented here
Manage relations between records with relation modes in Prisma | Pr...
Manage relations between records with relation modes in Prisma
RaphaelEtim
RaphaelEtim•4mo ago
When you use the relation mode, Prisma will not create foreign key constraints in the database. Relations are emulated by Prisma ORM using additional database queries and logic to maintain referential integrity
fwoelffel
fwoelffelOP•4mo ago
Thank you for your answer 🙂 I just edited my question because it didn't give enough details about my usecase. Do you know its possible to define the relation mode only for a set of tables?
RaphaelEtim
RaphaelEtim•4mo ago
It is not ot possible to define the relation mode only for a specific set of tables. The relation mode is set globally. We have an open issue for supporting weak relations. You may also want to take a look at this Github Discussion.
GitHub
Support (some) weak relations with no foreign key · Issue #7351 · p...
Problem I need a relation in my schema so that I can query across two tables, but without the referential integrity constraints that come with a foreign key. This is related to issue #7293, but dif...

Did you find this page helpful?