From 98c8bbda5750dbbf8c7bafa07291edd3affa0645 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 16 Jan 2023 16:28:17 -0500 Subject: [PATCH] Trending voices / analytics table --- .../down.sql | 5 +++ .../up.sql | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 _migrations/2023-01-16-211642_trending_model_analytics/down.sql create mode 100644 _migrations/2023-01-16-211642_trending_model_analytics/up.sql diff --git a/_migrations/2023-01-16-211642_trending_model_analytics/down.sql b/_migrations/2023-01-16-211642_trending_model_analytics/down.sql new file mode 100644 index 0000000000..04d03ee442 --- /dev/null +++ b/_migrations/2023-01-16-211642_trending_model_analytics/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE trending_model_analytics; diff --git a/_migrations/2023-01-16-211642_trending_model_analytics/up.sql b/_migrations/2023-01-16-211642_trending_model_analytics/up.sql new file mode 100644 index 0000000000..d42e4ecd42 --- /dev/null +++ b/_migrations/2023-01-16-211642_trending_model_analytics/up.sql @@ -0,0 +1,32 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- Periodically capture analytics on trending models +CREATE TABLE trending_model_analytics ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- The type of model. TTS, VC, etc. + model_type VARCHAR(32) NOT NULL, + + -- The primary key of the TTS, VC, or other model in question. + model_token VARCHAR(32) NOT NULL, + + -- The name of the window, eg. "last_24_hours", "last_5_hours", etc. + window_name VARCHAR(32) NOT NULL, + + -- The measured numerical value of the statistic, eg "500 uses" = 500. + numeric_value INT(10) NOT NULL DEFAULT 0, + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (model_token, model_type, window_name), + KEY index_model_type_model_token (model_type, model_token), + KEY index_model_token (model_token), + KEY index_numeric_value (numeric_value) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;