Files
server/util/Migrator/DbScripts/2026-04-13_01_AddBulkRevocationSprocs.sql
sven-bitwarden ec01e81b05 [PM-33866] Revocation Reasons: DDL Edition (#7432)
* Initial pass of revocation reason

* 2'nd pass, with tests, of revocation reason

* separate migration concerns, begin using new bulk sprocs

* remove old RevokeManyByIdAsync in favor of RevokeManyAsync

* fix migrations order

* Adjust other missing sprocs

* begrudgingly formats file

* No longer drop now-deprecated sprocs

* Add more views to refresh

* re-adds stored procs

* formatting from restoration

* Fix naming

* Modify sproc file name to match name
2026-04-15 14:20:45 -05:00

46 lines
1.1 KiB
Transact-SQL

-- Create OrganizationUser_RevokeMany
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_RevokeMany]
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
@RevocationReason TINYINT = NULL
AS
BEGIN
SET NOCOUNT ON
UPDATE
OU
SET
OU.[Status] = -1, -- Revoked
OU.[RevocationReason] = @RevocationReason
FROM
[dbo].[OrganizationUser] OU
INNER JOIN
@OrganizationUserIds OUI ON OUI.[Id] = OU.[Id]
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
END
GO
-- Create OrganizationUser_RestoreMany
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_RestoreMany]
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
@Status SMALLINT
AS
BEGIN
SET NOCOUNT ON
UPDATE
OU
SET
OU.[Status] = @Status,
OU.[RevocationReason] = NULL
FROM
[dbo].[OrganizationUser] OU
INNER JOIN
@OrganizationUserIds OUI ON OUI.[Id] = OU.[Id]
WHERE
OU.[Status] = -1 -- Only restore currently revoked users
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
END
GO