From 462016042ceda364ac98fc965e920a90ee179797 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 20 Jun 2025 16:41:37 +0200 Subject: [PATCH] Fix unique constraint hit during territory unarchive (#2245) --- api/paidAction/territoryUnarchive.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api/paidAction/territoryUnarchive.js b/api/paidAction/territoryUnarchive.js index 9f79963e..8cae77d9 100644 --- a/api/paidAction/territoryUnarchive.js +++ b/api/paidAction/territoryUnarchive.js @@ -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 }