mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00
[AC-1682] Removed MySql transaction from script because EF migration already wraps it under its own transaction
This commit is contained in:
@ -33,9 +33,7 @@
|
|||||||
`OU`.`Permissions` IS NOT NULL AND
|
`OU`.`Permissions` IS NOT NULL AND
|
||||||
JSON_VALID(`OU`.`Permissions`) AND JSON_VALUE(`OU`.`Permissions`, '$.editAssignedCollections') = 'true'));
|
JSON_VALID(`OU`.`Permissions`) AND JSON_VALUE(`OU`.`Permissions`, '$.editAssignedCollections') = 'true'));
|
||||||
|
|
||||||
-- Start transaction
|
-- Step 1
|
||||||
START TRANSACTION;
|
|
||||||
-- Step 1
|
|
||||||
-- Update existing rows in `CollectionGroups`
|
-- Update existing rows in `CollectionGroups`
|
||||||
UPDATE `CollectionGroups` `CG`
|
UPDATE `CollectionGroups` `CG`
|
||||||
INNER JOIN `Collection` `C` ON `CG`.`CollectionId` = `C`.`Id`
|
INNER JOIN `Collection` `C` ON `CG`.`CollectionId` = `C`.`Id`
|
||||||
@ -58,7 +56,7 @@ START TRANSACTION;
|
|||||||
SET `AccessAll` = 0, `RevisionDate` = UTC_TIMESTAMP()
|
SET `AccessAll` = 0, `RevisionDate` = UTC_TIMESTAMP()
|
||||||
WHERE `G`.`Id` IN (SELECT `GroupId` FROM `TempGroupsAccessAll`);
|
WHERE `G`.`Id` IN (SELECT `GroupId` FROM `TempGroupsAccessAll`);
|
||||||
|
|
||||||
-- Step 2
|
-- Step 2
|
||||||
-- Update existing rows in `CollectionUsers`
|
-- Update existing rows in `CollectionUsers`
|
||||||
UPDATE `CollectionUsers` `target`
|
UPDATE `CollectionUsers` `target`
|
||||||
INNER JOIN `Collection` `C` ON `target`.`CollectionId` = `C`.`Id`
|
INNER JOIN `Collection` `C` ON `target`.`CollectionId` = `C`.`Id`
|
||||||
@ -82,7 +80,7 @@ START TRANSACTION;
|
|||||||
SET `AccessAll` = 0, `RevisionDate` = UTC_TIMESTAMP()
|
SET `AccessAll` = 0, `RevisionDate` = UTC_TIMESTAMP()
|
||||||
WHERE `OU`.`Id` IN (SELECT `OrganizationUserId` FROM `TempUsersAccessAll`);
|
WHERE `OU`.`Id` IN (SELECT `OrganizationUserId` FROM `TempUsersAccessAll`);
|
||||||
|
|
||||||
-- Step 3
|
-- Step 3
|
||||||
-- Update `CollectionUsers` with `Manage` = 1 using the temporary table
|
-- Update `CollectionUsers` with `Manage` = 1 using the temporary table
|
||||||
UPDATE `CollectionUsers` `CU`
|
UPDATE `CollectionUsers` `CU`
|
||||||
INNER JOIN `TempUserManagers` `TUM` ON `CU`.`OrganizationUserId` = `TUM`.`OrganizationUserId`
|
INNER JOIN `TempUserManagers` `TUM` ON `CU`.`OrganizationUserId` = `TUM`.`OrganizationUserId`
|
||||||
@ -108,7 +106,7 @@ START TRANSACTION;
|
|||||||
SET `OU`.`Type` = 2, `OU`.`RevisionDate` = UTC_TIMESTAMP() -- User
|
SET `OU`.`Type` = 2, `OU`.`RevisionDate` = UTC_TIMESTAMP() -- User
|
||||||
WHERE `OU`.`Id` IN (SELECT `OrganizationUserId` FROM `TempUserManagers` WHERE `IsManager` = 1);
|
WHERE `OU`.`Id` IN (SELECT `OrganizationUserId` FROM `TempUserManagers` WHERE `IsManager` = 1);
|
||||||
|
|
||||||
-- Step 4
|
-- Step 4
|
||||||
-- Update `User` `AccountRevisionDate` for each unique `OrganizationUserId`
|
-- Update `User` `AccountRevisionDate` for each unique `OrganizationUserId`
|
||||||
UPDATE `User` `U`
|
UPDATE `User` `U`
|
||||||
INNER JOIN `OrganizationUser` `OU` ON `U`.`Id` = `OU`.`UserId`
|
INNER JOIN `OrganizationUser` `OU` ON `U`.`Id` = `OU`.`UserId`
|
||||||
@ -132,15 +130,11 @@ START TRANSACTION;
|
|||||||
) AS `CombinedOrgUsers` ON `OU`.`Id` = `CombinedOrgUsers`.`OrganizationUserId`
|
) AS `CombinedOrgUsers` ON `OU`.`Id` = `CombinedOrgUsers`.`OrganizationUserId`
|
||||||
SET `U`.`AccountRevisionDate` = UTC_TIMESTAMP();
|
SET `U`.`AccountRevisionDate` = UTC_TIMESTAMP();
|
||||||
|
|
||||||
-- Step 5
|
-- Step 5: Set `FlexibleCollections` = 1 for all organizations that have not yet been migrated.
|
||||||
-- Set `FlexibleCollections` = 1 for all organizations that have not yet been migrated.
|
|
||||||
UPDATE `Organization`
|
UPDATE `Organization`
|
||||||
SET `FlexibleCollections` = 1
|
SET `FlexibleCollections` = 1
|
||||||
WHERE `FlexibleCollections` = 0;
|
WHERE `FlexibleCollections` = 0;
|
||||||
|
|
||||||
-- Commit transaction
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
-- Step 6: Drop the temporary tables
|
-- Step 6: Drop the temporary tables
|
||||||
DROP TEMPORARY TABLE IF EXISTS `TempGroupsAccessAll`;
|
DROP TEMPORARY TABLE IF EXISTS `TempGroupsAccessAll`;
|
||||||
DROP TEMPORARY TABLE IF EXISTS `TempUsersAccessAll`;
|
DROP TEMPORARY TABLE IF EXISTS `TempUsersAccessAll`;
|
||||||
|
@ -123,8 +123,7 @@
|
|||||||
SELECT "OrganizationUserId" FROM "TempUserManagers"
|
SELECT "OrganizationUserId" FROM "TempUserManagers"
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Step 5
|
-- Step 5: Set "FlexibleCollections" = true for all organizations that have not yet been migrated.
|
||||||
-- Set "FlexibleCollections" = true for all organizations that have not yet been migrated.
|
|
||||||
UPDATE "Organization"
|
UPDATE "Organization"
|
||||||
SET "FlexibleCollections" = true
|
SET "FlexibleCollections" = true
|
||||||
WHERE "FlexibleCollections" = false;
|
WHERE "FlexibleCollections" = false;
|
||||||
|
@ -141,8 +141,7 @@
|
|||||||
) AS "CombinedOrgUsers" ON "OU"."Id" = "CombinedOrgUsers"."OrganizationUserId"
|
) AS "CombinedOrgUsers" ON "OU"."Id" = "CombinedOrgUsers"."OrganizationUserId"
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Step 5
|
-- Step 5: Set "FlexibleCollections" = 1 for all organizations that have not yet been migrated.
|
||||||
-- Set "FlexibleCollections" = 1 for all organizations that have not yet been migrated.
|
|
||||||
UPDATE "Organization"
|
UPDATE "Organization"
|
||||||
SET "FlexibleCollections" = 1
|
SET "FlexibleCollections" = 1
|
||||||
WHERE "FlexibleCollections" = 0;
|
WHERE "FlexibleCollections" = 0;
|
||||||
|
Reference in New Issue
Block a user