From ae38b81af11c227de781428f55bf975668509053 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Tue, 5 Mar 2024 22:28:47 +0200 Subject: [PATCH] chore: remove archived column from features table (#6431) This column has not been used for 1.5 years and was replace by **archived_at** column and people still get confused of why this is not working as name suggests. Removing this column to remove technical debt. --- .../feature-toggle/feature-toggle-store.ts | 12 +++++++----- .../20240305094305-features-remove-archived.js | 17 +++++++++++++++++ .../e2e/services/project-service.e2e.test.ts | 4 ---- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 src/migrations/20240305094305-features-remove-archived.js diff --git a/src/lib/features/feature-toggle/feature-toggle-store.ts b/src/lib/features/feature-toggle/feature-toggle-store.ts index b730c858c9..81de041613 100644 --- a/src/lib/features/feature-toggle/feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-store.ts @@ -300,10 +300,11 @@ export default class FeatureToggleStore implements IFeatureToggleStore { .count('type') .groupBy('type'); - query.where({ - project: projectId, - archived, - }); + query + .where({ + project: projectId, + }) + .modify(FeatureToggleStore.filterByArchived, archived); const result = await query; return result.map((row) => ({ @@ -677,7 +678,8 @@ export default class FeatureToggleStore implements IFeatureToggleStore { WHERE feature_types.id = features.type) * INTERVAL '1 day'))) as current_staleness FROM features - WHERE NOT stale = true AND archived_at IS NULL`, + WHERE NOT stale = true + AND archived_at IS NULL`, [currentTime || this.db.fn.now()], ); diff --git a/src/migrations/20240305094305-features-remove-archived.js b/src/migrations/20240305094305-features-remove-archived.js new file mode 100644 index 0000000000..dd97328744 --- /dev/null +++ b/src/migrations/20240305094305-features-remove-archived.js @@ -0,0 +1,17 @@ +exports.up = function (db, cb) { + db.runSql( + ` + ALTER TABLE features DROP COLUMN IF EXISTS archived; + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + ALTER TABLE features ADD COLUMN IF NOT EXISTS archived BOOLEAN DEFAULT FALSE; + `, + cb, + ); +}; diff --git a/src/test/e2e/services/project-service.e2e.test.ts b/src/test/e2e/services/project-service.e2e.test.ts index cb58a6ea2a..63762212bd 100644 --- a/src/test/e2e/services/project-service.e2e.test.ts +++ b/src/test/e2e/services/project-service.e2e.test.ts @@ -2070,19 +2070,15 @@ test('should get correct amount of features archived in current and past window' await Promise.all([ updateFeature(toggles[0].name, { archived_at: new Date(), - archived: true, }), updateFeature(toggles[1].name, { archived_at: new Date(), - archived: true, }), updateFeature(toggles[2].name, { archived_at: subDays(new Date(), 31), - archived: true, }), updateFeature(toggles[3].name, { archived_at: subDays(new Date(), 31), - archived: true, }), ]);