Fix unique constraint hit during territory unarchive (#2245)

This commit is contained in:
ekzyis 2025-06-20 16:41:37 +02:00 committed by GitHub
parent a5de2dae01
commit 462016042c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,9 +78,16 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) {
}
})
await tx.userSubTrust.createMany({
data: initialTrust({ name: updatedSub.name, userId: updatedSub.userId })
})
const trust = initialTrust({ name: updatedSub.name, userId: updatedSub.userId })
for (const t of trust) {
await tx.userSubTrust.upsert({
where: {
userId_subName: { userId: t.userId, subName: t.subName }
},
update: t,
create: t
})
}
return updatedSub
}