1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: add migration for old feature events (#1300)

When we change the feature events we introduced a new column
on the events table to ease resolving of feature related events,
instead of knowing the types and require the data object to include
a name property. This commit adds a migration to make sure we
convert all feature events.

fixes: #1299
This commit is contained in:
Ivar Conradi Østhus 2022-01-26 13:39:59 +01:00 committed by GitHub
parent 452416ca79
commit b8399abee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,22 @@
'use strict';
exports.up = function (db, cb) {
db.runSql(
`
UPDATE events
SET feature_name = E.feature_name
FROM (
SELECT id, data->>'name' AS feature_name
FROM events
WHERE type IN ('feature-created', 'feature-updated', 'feature-archived', 'feature-stale-on', 'feature-stale-off')
AND feature_name is null
) AS E
WHERE events.id = E.id;
`,
cb,
);
};
exports.down = function (db, cb) {
cb();
};