mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
[AC-1682] Added new mysql migration
This commit is contained in:
@ -10,6 +10,7 @@ SET @MaxBatch := (SELECT MAX(Batch) FROM TempOrgUser);
|
|||||||
SET @CurrentBatch := 0;
|
SET @CurrentBatch := 0;
|
||||||
|
|
||||||
-- Create the stored procedure
|
-- Create the stored procedure
|
||||||
|
DROP PROCEDURE IF EXISTS ProcessBatches;
|
||||||
CREATE PROCEDURE ProcessBatches(INOUT currentBatch INT, IN maxBatch INT)
|
CREATE PROCEDURE ProcessBatches(INOUT currentBatch INT, IN maxBatch INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
WHILE currentBatch <= maxBatch DO
|
WHILE currentBatch <= maxBatch DO
|
||||||
|
@ -1,8 +1,20 @@
|
|||||||
-- Update `CollectionUser` with `Manage` = 1 for all users with Manager role or 'EditAssignedCollections' permission
|
-- Update `CollectionUser` with `Manage` = 1 for all users with Manager role or 'EditAssignedCollections' permission
|
||||||
UPDATE CollectionUsers cu
|
UPDATE CollectionUsers cu
|
||||||
INNER JOIN OrganizationUser ou ON cu.OrganizationUserId = ou.Id
|
INNER JOIN OrganizationUser ou ON cu.OrganizationUserId = ou.Id
|
||||||
SET cu.ReadOnly = 0,
|
SET cu.ReadOnly = 0,
|
||||||
cu.HidePasswords = 0,
|
cu.HidePasswords = 0,
|
||||||
cu.Manage = 1
|
cu.Manage = 1
|
||||||
WHERE ou.Type = 3 OR (ou.Permissions IS NOT NULL AND
|
WHERE ou.Type = 3 OR (ou.Permissions IS NOT NULL AND
|
||||||
JSON_VALID(ou.Permissions) AND JSON_UNQUOTE(JSON_EXTRACT(ou.Permissions, '$.editAssignedCollections')) = 'true');
|
JSON_VALID(ou.Permissions) > 0 AND JSON_UNQUOTE(JSON_EXTRACT(ou.Permissions, '$.editAssignedCollections')) = 'true');
|
||||||
|
|
||||||
|
-- Insert rows to CollectionUser for Managers and users with 'EditAssignedCollections' permission assigned to groups with collection access
|
||||||
|
INSERT INTO CollectionUsers (CollectionId, OrganizationUserId, ReadOnly, HidePasswords, Manage)
|
||||||
|
SELECT cg.CollectionId, ou.Id, 0, 0, 1
|
||||||
|
FROM CollectionGroups cg
|
||||||
|
INNER JOIN GroupUser gu ON cg.GroupId = gu.GroupId
|
||||||
|
INNER JOIN OrganizationUser ou ON gu.OrganizationUserId = ou.Id
|
||||||
|
WHERE (ou.Type = 3 OR
|
||||||
|
(ou.Permissions IS NOT NULL AND JSON_VALID(ou.Permissions) > 0 AND JSON_UNQUOTE(JSON_EXTRACT(ou.Permissions, '$.editAssignedCollections')) = 'true'))
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM CollectionUsers cu
|
||||||
|
WHERE cu.CollectionId = cg.CollectionId AND cu.OrganizationUserId = ou.Id);
|
||||||
|
Reference in New Issue
Block a user