From c98901e94e4505ba76c16fff8d2a7786dfc8f525 Mon Sep 17 00:00:00 2001 From: Cy Okeke Date: Wed, 19 Nov 2025 19:45:44 +0100 Subject: [PATCH] Added the dependency check --- ...11-14_00_PopulateMaxStorageGbIncreased.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/util/Migrator/DbScripts/2025-11-14_00_PopulateMaxStorageGbIncreased.sql b/util/Migrator/DbScripts/2025-11-14_00_PopulateMaxStorageGbIncreased.sql index 2a2501e72b..5f312f89d6 100644 --- a/util/Migrator/DbScripts/2025-11-14_00_PopulateMaxStorageGbIncreased.sql +++ b/util/Migrator/DbScripts/2025-11-14_00_PopulateMaxStorageGbIncreased.sql @@ -1,3 +1,27 @@ + -- Dependency validation: Ensure PM-27603 has been deployed + -- This prevents cryptic "Invalid column name" errors + + IF NOT EXISTS ( + SELECT 1 FROM sys.columns + WHERE object_id = OBJECT_ID('[dbo].[User]') + AND name = 'MaxStorageGbIncreased' + ) + BEGIN + RAISERROR('MaxStorageGbIncreased column does not exist in User table. PM-27603 must be deployed first.', 16, 1); + RETURN; + END; + + IF NOT EXISTS ( + SELECT 1 FROM sys.columns + WHERE object_id = OBJECT_ID('[dbo].[Organization]') + AND name = 'MaxStorageGbIncreased' + ) + BEGIN + RAISERROR('MaxStorageGbIncreased column does not exist in Organization table. PM-27603 must be deployed first.', 16, 1); + RETURN; + END; + GO + -- Populate MaxStorageGbIncreased for Users in batches -- Set MaxStorageGbIncreased = MaxStorageGb + 4 for all users with storage quota -- Using batched updates to reduce lock contention and transaction log impact