Skip to content

Commit

Permalink
chore: remove archived column from features table (#6431)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjaanus committed Mar 5, 2024
1 parent 15db139 commit ae38b81
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/lib/features/feature-toggle/feature-toggle-store.ts
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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()],
);

Expand Down
17 changes: 17 additions & 0 deletions 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,
);
};
4 changes: 0 additions & 4 deletions src/test/e2e/services/project-service.e2e.test.ts
Expand Up @@ -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,
}),
]);

Expand Down

0 comments on commit ae38b81

Please sign in to comment.