P
Prisma6mo ago
dshun

Conditional Unique Constraint

Django offers a conditinal uniqueness constraint: Is there anything like this in prisma?
UniqueConstraint(
fields=['name', 'status'],
condition=Q(status=1),
name='unique_active_name',
]
UniqueConstraint(
fields=['name', 'status'],
condition=Q(status=1),
name='unique_active_name',
]
This is useful for the soft delete pattern, where anything that's "deleted" (but still in the DB) doesn't require the same constraints as the real active data
2 Replies
Nurul
Nurul6mo ago
Hey @dshun 👋 We have a feature request for it here: https://github.com/prisma/prisma/issues/6974 I would recommend you to have a look at this request, there are a few workarounds mentioned that might be helpful. Also, it would be great if you could give a 👍 to the request, so that our product team can prioritize this.
GitHub
Conditional uniqueness constraints; Partial/Filtered (Unique) Index...
Problem I would like to be able to define a uniqueness constraint that has conditional elements to it so that it can map to and align with a conditional unique index/constraint within the database....
dshun
dshunOP6mo ago
Thank you so much!
Want results from more Discord servers?
Add your server