Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing archivedAt to featureSchema (#1779)
* Added missing archivedAt to featureSchema * Added archivedAt to feature toggle. Added archived_at to db * Add test * Add test * Bug fix * Bug fix * update archivedAt to date-time * Code refactoring done * Conver to static and remove unused methods * Add tests * Fixes * Fix * Removed docker file from linting * Fix segment test * Fix failing test * Make fixes Co-authored-by: andreas-unleash <andreas@getunleash.ai> Co-authored-by: andreas-unleash <104830839+andreas-unleash@users.noreply.github.com>
- Loading branch information
1 parent
617955b
commit 04fb065
Showing
14 changed files
with
209 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/migrations/20220603081324-add-archive-at-to-feature-toggle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
exports.up = function (db, callback) { | ||
db.runSql( | ||
` | ||
ALTER TABLE features ADD archived_at TIMESTAMP WITH TIME ZONE; | ||
UPDATE features f | ||
SET archived_at = res.archived_at | ||
FROM (SELECT f.name, e.created_at AS archived_at | ||
FROM features f | ||
INNER JOIN events e | ||
ON e.feature_name = f.NAME | ||
AND e.created_at = | ||
(SELECT Max(created_at) date | ||
FROM events | ||
WHERE type = 'feature-archived' | ||
AND e.feature_name = f.NAME)) res | ||
WHERE res.NAME = f.NAME; | ||
UPDATE features | ||
SET archived_at = Now() | ||
WHERE archived = TRUE | ||
AND archived_at IS NULL; | ||
`, | ||
callback, | ||
); | ||
}; | ||
|
||
exports.down = function (db, callback) { | ||
db.runSql( | ||
` | ||
UPDATE features | ||
SET archived = TRUE | ||
WHERE archived_at IS NOT NULL; | ||
ALTER TABLE features DROP COLUMN archived_at; | ||
`, | ||
callback, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.