public Mono<Void> deleteRelationshipGroupAndMoveMembersToNewGroup(
            @NotNull Long ownerId,
            @NotNull Integer deleteGroupIndex,
            @NotNull Integer newGroupIndex) {
        try {
            Validator.notNull(ownerId, "ownerId");
            Validator.notNull(deleteGroupIndex, "deleteGroupIndex");
            Validator.notNull(newGroupIndex, "newGroupIndex");
            Validator.notEquals(deleteGroupIndex,
                    DEFAULT_RELATIONSHIP_GROUP_INDEX,
                    "The default relationship group cannot be deleted");
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        if (deleteGroupIndex.equals(newGroupIndex)) {
            return Mono.empty();
        }
        // Don't use transaction for better performance
        return userRelationshipGroupMemberRepository
                .findRelationshipGroupMembers(ownerId, deleteGroupIndex)
                .collect(CollectorUtil.toChunkedList())
                .flatMap(members -> {
                    if (members.isEmpty()) {
                        return Mono.empty();
                    }
                    List<UserRelationshipGroupMember> newMembers = new ArrayList<>(members.size());
                    Date now = new Date();
                    for (UserRelationshipGroupMember member : members) {
                        UserRelationshipGroupMember.Key memberKey = member.getKey();
                        UserRelationshipGroupMember groupMember = new UserRelationshipGroupMember(
                                memberKey.getOwnerId(),
                                newGroupIndex,
                                memberKey.getRelatedUserId(),
                                now);
                        newMembers.add(groupMember);
                    }
                    return userRelationshipGroupMemberRepository.insertAllOfSameType(newMembers)
                            .onErrorComplete(DuplicateKeyException.class);
                })
                .then(userRelationshipGroupMemberRepository
                        .deleteAllRelatedUserFromRelationshipGroup(ownerId, deleteGroupIndex))
                .then(userRelationshipGroupRepository
                        .deleteById(new UserRelationshipGroup.Key(ownerId, deleteGroupIndex)))
                .then(userVersionService.updateRelationshipGroupsVersion(ownerId)
                        .onErrorResume(t -> {
                            LOGGER.error(
                                    "Caught an error while updating the relationship groups version of the owner ({}) after deleting relationships",
                                    ownerId,
                                    t);
                            return Mono.empty();
                        }))
                .then();
    }
@return true if added a new related user to the relationship group.
@implNote We call this method while upserting a relationship into the owner's relationship
          group in a transaction currently, so we don't check whether the owner has a
          relationship with the related user in this method.
turms-service/src/main/java/im/turms/service/domain/user/service/UserRelationshipGroupService.java