mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-24 01:18:01 +02:00
chore: add migration for traffic data collection (#6171)
## About the changes Adds migration for creating table `stat_traffic_usage`. This table primary-keys on day, traffic_group, and status_code_series. Adds individual indexes for day, traffic_group, and status_code_series. Traffic group is the grouping for API endpoints for which traffic is counted. status_code_series is 200/202 etc = 200, 304 etc = 300
This commit is contained in:
parent
4c1dfbefa7
commit
1b1bde8aec
@ -0,0 +1,30 @@
|
||||
|
||||
exports.up = (db, callback) => {
|
||||
db.runSql(
|
||||
`
|
||||
CREATE TABLE IF NOT EXISTS stat_traffic_usage(
|
||||
day DATE NOT NULL,
|
||||
traffic_group TEXT NOT NULL,
|
||||
status_code_series INT NOT NULL,
|
||||
count BIGINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(day, traffic_group, status_code_series)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS stat_traffic_usage_day_idx ON stat_traffic_usage (day);
|
||||
CREATE INDEX IF NOT EXISTS stat_traffic_usage_traffic_group_idx ON stat_traffic_usage (traffic_group);
|
||||
CREATE INDEX IF NOT EXISTS stat_traffic_usage_status_code_series_idx ON stat_traffic_usage (status_code_series);
|
||||
`,
|
||||
callback,
|
||||
);
|
||||
};
|
||||
|
||||
exports.down = (db, callback) => {
|
||||
db.runSql(
|
||||
`
|
||||
DROP INDEX IF EXISTS stat_traffic_usage_day_idx;
|
||||
DROP INDEX IF EXISTS stat_traffic_usage_traffic_group_idx;
|
||||
DROP INDEX IF EXISTS stat_traffic_usage_status_code_series_idx;
|
||||
DROP TABLE IF EXISTS stat_traffic_usage;
|
||||
`,
|
||||
callback,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user