From 6ea9e961e3168d4711b2d3d63c0bbd1b17c302a1 Mon Sep 17 00:00:00 2001 From: kwasniew Date: Fri, 26 Jan 2024 11:00:57 +0100 Subject: [PATCH] feat: flag trends db migration --- .../20240126095544-add-flag-trends.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/migrations/20240126095544-add-flag-trends.js diff --git a/src/migrations/20240126095544-add-flag-trends.js b/src/migrations/20240126095544-add-flag-trends.js new file mode 100644 index 000000000000..cea29227057f --- /dev/null +++ b/src/migrations/20240126095544-add-flag-trends.js @@ -0,0 +1,21 @@ +'use strict'; + +exports.up = function(db, cb) { + db.runSql( + ` + CREATE TABLE IF NOT EXISTS flag_trends ( + id VARCHAR(255) NOT NULL, + project VARCHAR(255) NOT NULL REFERENCES projects (id) ON DELETE CASCADE, + total_flags INTEGER NOT NULL, + stale_flags INTEGER NOT NULL, + potentially_stale_flags INTEGER NOT NULL, + created_at TIMESTAMP default now(), + PRIMARY KEY (id, project) + );`, + cb, + ); +}; + +exports.down = function(db, cb) { + db.runSql('DROP TABLE IF EXISTS flag_trends;', cb); +};