File tree Expand file tree Collapse file tree
services/libs/data-access-layer/src/members Expand file tree Collapse file tree Original file line number Diff line number Diff 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
253267export async function cleanSoftDeletedMemberOrganization (
You can’t perform that action at this time.
0 commit comments