mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
[AC-1682] Setting FlexibleCollections = 1 only for Orgs that had data migrated in previous steps
This commit is contained in:
parent
7b54d78d67
commit
28bba94d81
@ -131,11 +131,25 @@
|
||||
SET `U`.`AccountRevisionDate` = UTC_TIMESTAMP();
|
||||
|
||||
-- Step 5: Set `FlexibleCollections` = 1 for all organizations that have not yet been migrated.
|
||||
UPDATE `Organization`
|
||||
SET `FlexibleCollections` = 1
|
||||
WHERE `FlexibleCollections` = 0;
|
||||
UPDATE `Organization` AS `O`
|
||||
JOIN (
|
||||
SELECT DISTINCT `TG`.`OrganizationId`
|
||||
FROM `TempGroupsAccessAll` AS `TG`
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT `TU`.`OrganizationId`
|
||||
FROM `TempUsersAccessAll` AS `TU`
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT `OU`.`OrganizationId`
|
||||
FROM `TempUserManagers` AS `OU`
|
||||
) AS `TempOrgIds` ON `O`.`Id` = `TempOrgIds`.`OrganizationId`
|
||||
SET `O`.`FlexibleCollections` = 1
|
||||
WHERE `O`.`FlexibleCollections` = 0;
|
||||
|
||||
-- Step 6: Drop the temporary tables
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempGroupsAccessAll`;
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempUsersAccessAll`;
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempUserManagers`;
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempGroupsAccessAll`;
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempUsersAccessAll`;
|
||||
DROP TEMPORARY TABLE IF EXISTS `TempUserManagers`;
|
||||
|
@ -124,12 +124,27 @@
|
||||
);
|
||||
|
||||
-- Step 5: Set "FlexibleCollections" = true for all organizations that have not yet been migrated.
|
||||
UPDATE "Organization"
|
||||
UPDATE "Organization" AS "O"
|
||||
SET "FlexibleCollections" = true
|
||||
WHERE "FlexibleCollections" = false;
|
||||
FROM (
|
||||
SELECT DISTINCT "TG"."OrganizationId"
|
||||
FROM "TempGroupsAccessAll" AS "TG"
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT "TU"."OrganizationId"
|
||||
FROM "TempUsersAccessAll" AS "TU"
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT "OU"."OrganizationId"
|
||||
FROM "TempUserManagers" AS "OU"
|
||||
) AS "TempOrgIds"
|
||||
WHERE "O"."Id" = "TempOrgIds"."OrganizationId"
|
||||
AND "O"."FlexibleCollections" = false;
|
||||
|
||||
-- Step 6: Drop the temporary tables
|
||||
DROP TABLE IF EXISTS "TempGroupsAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUsersAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUserManagers";
|
||||
DROP TABLE IF EXISTS "TempGroupsAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUsersAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUserManagers";
|
||||
|
||||
|
@ -144,10 +144,22 @@
|
||||
-- Step 5: Set "FlexibleCollections" = 1 for all organizations that have not yet been migrated.
|
||||
UPDATE "Organization"
|
||||
SET "FlexibleCollections" = 1
|
||||
WHERE "FlexibleCollections" = 0;
|
||||
WHERE "Id" IN (
|
||||
SELECT DISTINCT "TG"."OrganizationId"
|
||||
FROM "TempGroupsAccessAll" AS "TG"
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT "TU"."OrganizationId"
|
||||
FROM "TempUsersAccessAll" AS "TU"
|
||||
|
||||
UNION
|
||||
|
||||
SELECT DISTINCT "OU"."OrganizationId"
|
||||
FROM "TempUserManagers" AS "OU"
|
||||
) AND "FlexibleCollections" = 0;
|
||||
|
||||
-- Step 6: Drop the temporary tables
|
||||
DROP TABLE IF EXISTS "TempGroupsAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUsersAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUserManagers";
|
||||
DROP TABLE IF EXISTS "TempGroupsAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUsersAccessAll";
|
||||
DROP TABLE IF EXISTS "TempUserManagers";
|
||||
|
Loading…
Reference in New Issue
Block a user