diff --git a/src/migrations/20240821141555-segment-no-project-cleanup.js b/src/migrations/20240821141555-segment-no-project-cleanup.js new file mode 100644 index 0000000000..75abd5a8f5 --- /dev/null +++ b/src/migrations/20240821141555-segment-no-project-cleanup.js @@ -0,0 +1,25 @@ +'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, + ); +};