1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00
unleash.unleash/src/migrations/20240821141555-segment-no-project-cleanup.js
Jaanus Sellin 99e4a564d0
fix: fix events with no-project projects (#7951)
Fixes issue where `segment-created `events had fake project name
**no-project** attached.

In total for previous 4 months, all segments created that were global
segments, have this issue.


https://github.com/Unleash/unleash/pull/6872/files#diff-68dcd43b31d35a8a80c73bca1f2a9626b0234dd0b76920a6881b81fa04708268R135
2024-08-21 15:32:37 +03:00

26 lines
463 B
JavaScript

'use strict';
exports.up = function (db, callback) {
db.runSql(
`
UPDATE events
SET project = NULL
WHERE type = 'segment-created'
AND project = 'no-project'
AND NOT EXISTS (
SELECT 1
FROM projects
WHERE name = 'no-project'
);
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
``,
callback,
);
};