1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Change OrgUser Delete Behavior (#2010)

* Fix OrgUserDelete sprocs

* Update Sqlproj
This commit is contained in:
Justin Baur 2022-05-23 15:50:54 -04:00 committed by GitHub
parent 0c925f92c9
commit f235938c41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 2 deletions

View File

@ -7,7 +7,7 @@ BEGIN
UPDATE
OS
SET
[SponsoringOrganizationUserId] = NULL
[ToDelete] = 1
FROM
[dbo].[OrganizationSponsorship] OS
WHERE

View File

@ -7,7 +7,7 @@ BEGIN
UPDATE
OS
SET
[SponsoringOrganizationUserId] = NULL
[ToDelete] = 1
FROM
[dbo].[OrganizationSponsorship] OS
INNER JOIN

View File

@ -0,0 +1,47 @@
-- OrganizationSponsorship_OrganizationUserDeleted
IF OBJECT_ID('[dbo].[OrganizationSponsorship_OrganizationUserDeleted]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUserDeleted]
END
GO
CREATE PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUserDeleted]
@OrganizationUserId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
UPDATE
OS
SET
[ToDelete] = 1
FROM
[dbo].[OrganizationSponsorship] OS
WHERE
[SponsoringOrganizationUserId] = @OrganizationUserId
END
GO
-- OrganizationSponsorship_OrganizationUsersDeleted
IF OBJECT_ID('[dbo].[OrganizationSponsorship_OrganizationUsersDeleted]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUsersDeleted]
END
GO
CREATE PROCEDURE [dbo].[OrganizationSponsorship_OrganizationUsersDeleted]
@SponsoringOrganizationUserIds [dbo].[GuidIdArray] READONLY
AS
BEGIN
SET NOCOUNT ON
UPDATE
OS
SET
[ToDelete] = 1
FROM
[dbo].[OrganizationSponsorship] OS
INNER JOIN
@SponsoringOrganizationUserIds I ON I.Id = OS.SponsoringOrganizationUserId
END
GO