mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
updated format of import data
This commit is contained in:
@ -190,5 +190,6 @@
|
||||
<Build Include="dbo\Stored Procedures\OrganizationUser_UpdateWithCollections.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CollectionUser_Delete.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_ReadByOrganizationId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\GroupUser_UpdateUsers.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
46
src/Sql/dbo/Stored Procedures/GroupUser_UpdateUsers.sql
Normal file
46
src/Sql/dbo/Stored Procedures/GroupUser_UpdateUsers.sql
Normal file
@ -0,0 +1,46 @@
|
||||
CREATE PROCEDURE [dbo].[GroupUser_UpdateUsers]
|
||||
@GroupId UNIQUEIDENTIFIER,
|
||||
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @OrgId UNIQUEIDENTIFIER = (
|
||||
SELECT TOP 1
|
||||
[OrganizationId]
|
||||
FROM
|
||||
[dbo].[Group]
|
||||
WHERE
|
||||
[Id] = @GroupId
|
||||
)
|
||||
|
||||
;WITH [AvailableUsersCTE] AS(
|
||||
SELECT
|
||||
[Id]
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
[OrganizationId] = @OrgId
|
||||
)
|
||||
MERGE
|
||||
[dbo].[GroupUser] AS [Target]
|
||||
USING
|
||||
@OrganizationUserIds AS [Source]
|
||||
ON
|
||||
[Target].[GroupId] = @GroupId
|
||||
AND [Target].[OrganizationUserId] = [Source].[Id]
|
||||
WHEN NOT MATCHED BY TARGET
|
||||
AND [Source].[Id] IN (SELECT [Id] FROM [AvailableUsersCTE]) THEN
|
||||
INSERT VALUES
|
||||
(
|
||||
@GroupId,
|
||||
[Source].[Id]
|
||||
)
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[GroupId] = @GroupId
|
||||
AND [Target].[OrganizationUserId] IN (SELECT [Id] FROM [AvailableUsersCTE]) THEN
|
||||
DELETE
|
||||
;
|
||||
|
||||
-- TODO: Bump account revision date for all @OrganizationUserIds
|
||||
END
|
Reference in New Issue
Block a user