1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

[AC-1682] Updated AccessAllCollectionGroups migration script to use User_BumpAccountRevisionDateByCollectionId

This commit is contained in:
Rui Tome
2024-01-11 13:58:45 +00:00
parent f4450c082c
commit 8cc889554d

View File

@ -29,27 +29,29 @@ SET [AccessAll] = 0
FROM [dbo].[Group] G FROM [dbo].[Group] G
INNER JOIN #TempGroup TG ON G.[Id] = TG.[GroupId] INNER JOIN #TempGroup TG ON G.[Id] = TG.[GroupId]
-- Step 5: Bump the account revision date for each unique OrganizationId in #TempGroup -- Step 5: Bump the account revision date for each unique CollectionId and OrganizationId
DECLARE @CollectionId UNIQUEIDENTIFIER
DECLARE @OrganizationId UNIQUEIDENTIFIER DECLARE @OrganizationId UNIQUEIDENTIFIER
DECLARE OrgIdCursor CURSOR FOR DECLARE CollectionIdCursor CURSOR FOR
SELECT DISTINCT [OrganizationId] SELECT DISTINCT C.[Id], C.[OrganizationId]
FROM #TempGroup FROM [dbo].[Collection] C
INNER JOIN #TempGroup TG ON C.[OrganizationId] = TG.[OrganizationId]
OPEN OrgIdCursor OPEN CollectionIdCursor
FETCH NEXT FROM OrgIdCursor INTO @OrganizationId FETCH NEXT FROM CollectionIdCursor INTO @CollectionId, @OrganizationId
WHILE (@@FETCH_STATUS = 0) WHILE (@@FETCH_STATUS = 0)
BEGIN BEGIN
-- Execute the stored procedure for the current OrganizationId -- Execute the stored procedure for the current CollectionId and OrganizationId
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @OrganizationId EXEC [dbo].[User_BumpAccountRevisionDateByCollectionId] @CollectionId, @OrganizationId
-- Fetch the next OrganizationId -- Fetch the next CollectionId and OrganizationId
FETCH NEXT FROM OrgIdCursor INTO @OrganizationId FETCH NEXT FROM CollectionIdCursor INTO @CollectionId, @OrganizationId
END END
CLOSE OrgIdCursor CLOSE CollectionIdCursor
DEALLOCATE OrgIdCursor; DEALLOCATE CollectionIdCursor;
-- Step 6: Drop the temporary table -- Step 6: Drop the temporary table
DROP TABLE #TempGroup; DROP TABLE #TempGroup;