1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-18 13:48:58 +02:00

feat: lifecycle trends migration (#10066)

Adding a single table to capture all lifecycle trends data.

One field presents a challenge: `median_time_in_stage_days`. This value
is calculated per `stage`, not per `flag_type`. As a result, we would
need to duplicate the total median time across each flag type. This
isn’t a major issue.

An alternative would be to create a separate table solely for the median
values, but that seems like overkill.
This commit is contained in:
Jaanus Sellin 2025-06-03 08:55:28 +03:00 committed by GitHub
parent 5be0b37cb1
commit e474abb946
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,23 @@
'use strict';
exports.up = function(db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS lifecycle_trends (
id TEXT NOT NULL,
stage TEXT NOT NULL CHECK (stage IN ('initial','develop', 'production', 'cleanup', 'archived')),
flag_type TEXT NOT NULL CHECK (flag_type IN ('experimental', 'release', 'permanent')),
project VARCHAR(255) NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
flags_older_than_week INTEGER DEFAULT 0,
new_flags_this_week INTEGER DEFAULT 0,
created_at TIMESTAMP DEFAULT now(),
PRIMARY KEY (id, stage, flag_type, project)
);
`,
cb,
);
};
exports.down = function(db, cb) {
db.runSql('DROP TABLE IF EXISTS lifecycle_trends;', cb);
};