Skip to content

Commit

Permalink
fix: add migration for old feature events (#1300)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ivarconr committed Jan 26, 2022
1 parent 452416c commit b8399ab
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/migrations/20220125200908-convert-old-feature-events.js
Original file line number Diff line number Diff line change
@@ -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();
};

0 comments on commit b8399ab

Please sign in to comment.