Skip to content

Commit 09ccc0c

Browse files
authored
fix: add hard deleting when deleting a memberOrganization (#3464)
1 parent fb219c6 commit 09ccc0c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

services/libs/data-access-layer/src/members/organizations.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,23 @@ export async function deleteMemberOrganizations(
245245
params.ids = ids
246246
}
247247

248-
const query = `${baseQuery} WHERE ${conditions.join(' AND ')};`
248+
const whereClause = conditions.join(' AND ')
249+
const query = `${baseQuery} WHERE ${whereClause};`
249250

250-
await qx.result(query, params)
251+
await qx.tx(async (tx) => {
252+
// First delete from memberOrganizationAffiliationOverrides using the same conditions
253+
await tx.result(
254+
`DELETE FROM "memberOrganizationAffiliationOverrides"
255+
WHERE "memberOrganizationId" IN (
256+
SELECT "id" FROM "memberOrganizations"
257+
WHERE ${whereClause}
258+
)`,
259+
params,
260+
)
261+
262+
// Then perform the soft/hard delete on memberOrganizations
263+
await tx.result(query, params)
264+
})
251265
}
252266

253267
export async function cleanSoftDeletedMemberOrganization(

0 commit comments

Comments
 (0)