PrismaP
Prisma2y ago
3 replies
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',
]

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
Was this page helpful?