diff --git a/util/MySqlMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql b/util/MySqlMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql index ee33bf099..d3a2ec8c3 100644 --- a/util/MySqlMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql +++ b/util/MySqlMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql @@ -133,23 +133,9 @@ SET `U`.`AccountRevisionDate` = UTC_TIMESTAMP(); -- Step 5: Set `FlexibleCollections` = 1 for all organizations that have not yet been migrated. - 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; + UPDATE `Organization` + SET `FlexibleCollections` = 1 + WHERE `FlexibleCollections` = 0; -- Step 6: Drop the temporary tables DROP TEMPORARY TABLE IF EXISTS `TempGroupsAccessAll`; diff --git a/util/PostgresMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.psql b/util/PostgresMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.psql index af06edf25..d66dec5a7 100644 --- a/util/PostgresMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.psql +++ b/util/PostgresMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.psql @@ -123,31 +123,20 @@ SELECT "OrganizationUserId" FROM "GroupUser" WHERE "GroupId" IN (SELECT "GroupId" FROM "TempGroupsAccessAll") + UNION + SELECT "OrganizationUserId" FROM "TempUsersAccessAll" + UNION + SELECT "OrganizationUserId" FROM "TempUserManagers" ); -- Step 5: Set "FlexibleCollections" = true for all organizations that have not yet been migrated. - UPDATE "Organization" AS "O" + UPDATE "Organization" SET "FlexibleCollections" = true - 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; + WHERE "FlexibleCollections" = false; -- Step 6: Drop the temporary tables DROP TABLE IF EXISTS "TempGroupsAccessAll"; diff --git a/util/SqliteMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql b/util/SqliteMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql index e29acde0c..3582fb860 100644 --- a/util/SqliteMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql +++ b/util/SqliteMigrations/HelperScripts/2024-03-22_00_EnableOrgsCollectionEnhancements.sql @@ -123,11 +123,11 @@ WHERE "Id" IN ( SELECT DISTINCT "OU"."UserId" FROM "OrganizationUser" "OU" - INNER JOIN ( + INNER JOIN ( -- Step 1 SELECT "GU"."OrganizationUserId" FROM "GroupUser" "GU" - INNER JOIN "TempGroupsAccessAll" "TG" ON "GU"."GroupId" = "TG"."GroupId" + INNER JOIN "TempGroupsAccessAll" "TG" ON "GU"."GroupId" = "TG"."GroupId" UNION @@ -146,20 +146,7 @@ -- Step 5: Set "FlexibleCollections" = 1 for all organizations that have not yet been migrated. UPDATE "Organization" SET "FlexibleCollections" = 1 - 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; + WHERE "FlexibleCollections" = 0; -- Step 6: Drop the temporary tables DROP TABLE IF EXISTS "TempGroupsAccessAll";