From fcbe9fb8a491bf456750e10dec1e663ea27c5350 Mon Sep 17 00:00:00 2001 From: Vignesh S Date: Wed, 12 Mar 2025 08:00:01 +0530 Subject: [PATCH 1/2] Fix features table migrations in 20220603081324-add-archive-at-to-feature-toggle.js Fixes the migration script where features table is updated with archived_at column where there is an ambiguity in the SQL statement. --- .../20220603081324-add-archive-at-to-feature-toggle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js b/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js index 6c356d52cd45..4e7f7b720798 100644 --- a/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js +++ b/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js @@ -13,7 +13,7 @@ exports.up = function (db, callback) { AND e.created_at = (SELECT Max(created_at) date FROM events - WHERE type = 'feature-archived' + WHERE e.type = 'feature-archived' AND e.feature_name = f.NAME)) res WHERE res.NAME = f.NAME; UPDATE features From 68a7767180ffebfdb70c9bcd55cf1b447f8a45fe Mon Sep 17 00:00:00 2001 From: Vignesh S Date: Wed, 12 Mar 2025 13:48:05 +0530 Subject: [PATCH 2/2] Fix migration in 20220603081324-add-archive-at-to-feature-toggle.js Fixes the query so that instead of using the outer join's event e. Use additional check if the toggle was archived using features table's archived flag. Without this its updating the archived_at for all the existing features after migration --- .../20220603081324-add-archive-at-to-feature-toggle.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js b/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js index 4e7f7b720798..c0324ec5ff80 100644 --- a/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js +++ b/src/migrations/20220603081324-add-archive-at-to-feature-toggle.js @@ -13,8 +13,9 @@ exports.up = function (db, callback) { AND e.created_at = (SELECT Max(created_at) date FROM events - WHERE e.type = 'feature-archived' - AND e.feature_name = f.NAME)) res + WHERE type = 'feature-archived' + AND feature_name = f.NAME + AND f.archived = 't')) res WHERE res.NAME = f.NAME; UPDATE features SET archived_at = Now()