1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/src/migrations/20211004104917-client-metrics-env.js
Ivar Conradi Østhus fc455811f8
feat/metricsV2 (#1005)
Adds a new way of handling usage metrics where we push it directly to the database and performs aggregation on the fly. All metrics are aggregated in to buckets of hours. We will for now store metrics for the 48 hours with the following dimensions:

- featureName
- projectName
- envrionment
- yes (the actual count)
- no (the actual count)
2021-10-08 10:09:22 +02:00

29 lines
689 B
JavaScript

exports.up = function (db, cb) {
// TODO: foreign key on env.
db.runSql(
`
CREATE TABLE client_metrics_env(
feature_name VARCHAR(255),
app_name VARCHAR(255),
environment VARCHAR(100),
timestamp TIMESTAMP WITH TIME ZONE,
yes INTEGER DEFAULT 0,
no INTEGER DEFAULT 0,
PRIMARY KEY (feature_name, app_name, environment, timestamp)
);
CREATE INDEX idx_client_metrics_f_name ON client_metrics_env(feature_name);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
DROP TABLE client_metrics_env;
`,
cb,
);
};