-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: daily metrics db migration (#5791)
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
}; |