mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[AC-1682] Update FC data migration scripts to clear AccessAll flags and set all Managers to Users
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
-- Create a temporary table to store the groups with AccessAll = 1
|
||||
-- Step 1: Create a temporary table to store the Groups with AccessAll = 1
|
||||
SELECT [Id] AS [GroupId], [OrganizationId]
|
||||
INTO #TempGroup
|
||||
FROM [dbo].[Group]
|
||||
WHERE [AccessAll] = 1;
|
||||
|
||||
-- Update existing rows in [dbo].[CollectionGroup]
|
||||
-- Step 2: Update existing rows in [dbo].[CollectionGroup]
|
||||
UPDATE CG
|
||||
SET
|
||||
CG.[ReadOnly] = 0,
|
||||
@ -15,7 +15,7 @@ INNER JOIN [dbo].[Collection] C ON CG.[CollectionId] = C.[Id]
|
||||
INNER JOIN #TempGroup TG ON CG.[GroupId] = TG.[GroupId]
|
||||
WHERE C.[OrganizationId] = TG.[OrganizationId];
|
||||
|
||||
-- Insert new rows into [dbo].[CollectionGroup]
|
||||
-- Step 3: Insert new rows into [dbo].[CollectionGroup]
|
||||
INSERT INTO [dbo].[CollectionGroup] ([CollectionId], [GroupId], [ReadOnly], [HidePasswords], [Manage])
|
||||
SELECT C.[Id], TG.[GroupId], 0, 0, 0
|
||||
FROM [dbo].[Collection] C
|
||||
@ -23,5 +23,11 @@ FROM [dbo].[Collection] C
|
||||
LEFT JOIN [dbo].[CollectionGroup] CG ON CG.[CollectionId] = C.[Id] AND CG.[GroupId] = TG.[GroupId]
|
||||
WHERE CG.[CollectionId] IS NULL;
|
||||
|
||||
-- Drop the temporary table
|
||||
-- Step 4: Update [dbo].[Group] to clear AccessAll flag
|
||||
UPDATE G
|
||||
SET [AccessAll] = 0
|
||||
FROM [dbo].[Group] G
|
||||
INNER JOIN #TempGroup TG ON G.[Id] = TG.[GroupId]
|
||||
|
||||
-- Step 5: Drop the temporary table
|
||||
DROP TABLE #TempGroup;
|
||||
|
Reference in New Issue
Block a user