mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
26 lines
651 B
JavaScript
26 lines
651 B
JavaScript
|
'use strict';
|
||
|
|
||
|
exports.up = function (db, cb) {
|
||
|
db.runSql(
|
||
|
`
|
||
|
ALTER TABLE features ADD COLUMN IF NOT EXISTS potentially_stale boolean;
|
||
|
UPDATE features
|
||
|
SET potentially_stale = TRUE
|
||
|
FROM feature_types
|
||
|
WHERE feature_types.id = features.type
|
||
|
AND CURRENT_TIMESTAMP > (features.created_at + (feature_types.lifetime_days * INTERVAL '1 day'))
|
||
|
AND features.stale IS NOT TRUE;
|
||
|
`,
|
||
|
cb,
|
||
|
);
|
||
|
};
|
||
|
|
||
|
exports.down = function (db, cb) {
|
||
|
db.runSql(
|
||
|
`
|
||
|
ALTER table features DROP COLUMN IF EXISTS potentially_stale;
|
||
|
`,
|
||
|
cb,
|
||
|
);
|
||
|
};
|