Skip to content

Commit

Permalink
feat: daily metrics db migration (#5791)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Jan 9, 2024
1 parent 24b4e8d commit 99b1657
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/migrations/20240108151652-add-daily-metrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS client_metrics_env_daily (
feature_name VARCHAR(255),
app_name VARCHAR(255),
environment VARCHAR(100),
date DATE,
yes INTEGER DEFAULT 0,
no INTEGER DEFAULT 0,
PRIMARY KEY (feature_name, app_name, environment, date)
);
CREATE TABLE IF NOT EXISTS client_metrics_env_variants_daily (
feature_name VARCHAR(255),
app_name VARCHAR(255),
environment VARCHAR(100),
date DATE,
variant TEXT,
count INTEGER DEFAULT 0,
FOREIGN KEY (
feature_name, app_name, environment,
date
) REFERENCES client_metrics_env_daily (
feature_name, app_name, environment,
date
) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY(
feature_name, app_name, environment,
date, variant
)
);
`,
cb,
);
};

exports.down = function (db, cb) {
db.runSql(
`
DROP TABLE client_metrics_env_variants_daily;
DROP TABLE client_metrics_env_daily;
`,
cb,
);
};

0 comments on commit 99b1657

Please sign in to comment.