Skip to content

Commit

Permalink
feat: daily metrics db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Jan 8, 2024
1 parent 68d7af9 commit 5fb46f6
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),
timestamp TIMESTAMP WITH TIME ZONE,
yes INTEGER DEFAULT 0,
no INTEGER DEFAULT 0,
PRIMARY KEY (feature_name, app_name, environment, timestamp)
);
CREATE TABLE IF NOT EXISTS client_metrics_env_variants_daily (
feature_name VARCHAR(255),
app_name VARCHAR(255),
environment VARCHAR(100),
timestamp TIMESTAMP WITH TIME ZONE,
variant TEXT,
count INTEGER DEFAULT 0,
FOREIGN KEY (
feature_name, app_name, environment,
timestamp
) REFERENCES client_metrics_env_daily (
feature_name, app_name, environment,
timestamp
) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY(
feature_name, app_name, environment,
timestamp, variant
)
);
`,
cb,
);
};

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

0 comments on commit 5fb46f6

Please sign in to comment.