@@ -808,7 +808,7 @@ class OrganizationRepository {
808
808
fromOrganizationId : string ,
809
809
toOrganizationId : string ,
810
810
options : IRepositoryOptions ,
811
- ) : Promise < string [ ] > {
811
+ ) : Promise < void > {
812
812
const seq = SequelizeRepository . getSequelize ( options )
813
813
814
814
const transaction = SequelizeRepository . getTransaction ( options )
@@ -817,8 +817,6 @@ class OrganizationRepository {
817
817
818
818
let addRoles : IMemberOrganization [ ] = [ ]
819
819
820
- const updatedMembers = new Set < string > ( )
821
-
822
820
// first, handle members that belong to both organizations,
823
821
// then make a full update on remaining org2 members (that doesn't belong to o1)
824
822
const memberRolesWithBothOrganizations = await this . findMembersBelongToBothOrganizations (
@@ -917,50 +915,38 @@ class OrganizationRepository {
917
915
918
916
for ( const removeRole of removeRoles ) {
919
917
await this . removeMemberRole ( removeRole , options )
920
- updatedMembers . add ( removeRole . memberId )
921
918
}
922
919
923
920
for ( const addRole of addRoles ) {
924
921
await this . addMemberRole ( addRole , options )
925
- updatedMembers . add ( addRole . memberId )
926
922
}
927
923
928
924
addRoles = [ ]
929
925
removeRoles = [ ]
930
926
}
931
927
932
928
// update rest of the o2 members
933
- const results = await seq . query (
929
+ await seq . query (
934
930
`
935
- WITH updated AS (
936
- UPDATE "memberOrganizations"
931
+ UPDATE "memberOrganizations"
937
932
SET "organizationId" = :toOrganizationId
938
933
WHERE "organizationId" = :fromOrganizationId
939
934
AND "deletedAt" IS NULL
940
935
AND "memberId" NOT IN (
941
936
SELECT "memberId"
942
937
FROM "memberOrganizations"
943
938
WHERE "organizationId" = :toOrganizationId
944
- )
945
- RETURNING "memberId"
946
- )
947
- SELECT "memberId" FROM updated;
939
+ );
948
940
` ,
949
941
{
950
942
replacements : {
951
943
toOrganizationId,
952
944
fromOrganizationId,
953
945
} ,
954
- type : QueryTypes . SELECT ,
946
+ type : QueryTypes . UPDATE ,
955
947
transaction,
956
948
} ,
957
949
)
958
-
959
- for ( const result of results ) {
960
- updatedMembers . add ( ( result as any ) . memberId )
961
- }
962
-
963
- return Array . from ( updatedMembers )
964
950
}
965
951
966
952
static async getOrganizationSegments (
0 commit comments