1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-11 15:17:44 +01:00
bitwarden-server/util/Migrator/DbScripts/2024-11-06-00_OrgUserSetStatusBulk.sql

29 lines
761 B
MySQL
Raw Normal View History

2024-11-15 16:49:02 +01:00
CREATE PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersById]
@OrganizationUserIds AS NVARCHAR(MAX),
2024-11-07 22:51:18 +01:00
@Status SMALLINT
AS
BEGIN
SET NOCOUNT ON
2024-11-15 16:49:02 +01:00
-- Declare a table variable to hold the parsed JSON data
DECLARE @ParsedIds TABLE (Id UNIQUEIDENTIFIER);
-- Parse the JSON input into the table variable
INSERT INTO @ParsedIds (Id)
SELECT value
FROM OPENJSON(@OrganizationUserIds);
-- Check if the input table is empty
IF (SELECT COUNT(1) FROM @ParsedIds) < 1
BEGIN
RETURN(-1);
END
2024-11-07 22:51:18 +01:00
UPDATE
[dbo].[OrganizationUser]
2024-11-15 16:49:02 +01:00
SET [Status] = @Status
WHERE [Id] IN (SELECT Id from @ParsedIds)
2024-11-07 22:51:18 +01:00
2024-11-15 16:49:02 +01:00
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
END