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 }