Joey
09/30/2022, 2:19 PMorganizationId String?
field and a required name String
field.
Is there any way to enforce that two teams in the same organization don’t have the same name, BUT also allow many Teams with the same name if they’re not affiliated with an organization (organizationId = null)?
So my goal would be :
name: “joe”, orgId: null + name:“joe”, orgId:null === OK
name: ’joe”, orgId: 1 + name:“joe”, orgId:2 === OK
name: ’joe”, orgId: 1 + name:“joe”, orgId:1 === err: DUPLICATE
I usually do @@unique([name, organizationId])
, but i think this would cause the first example to fail when it shouldnt, bc both are null, but i want to allow that.Nurul
09/30/2022, 2:36 PMJoey
09/30/2022, 3:38 PMJoey
09/30/2022, 3:41 PMNurul
09/30/2022, 3:44 PM