mirror of
git://f0xx.org/ac/ac-ms-graphs
synced 2026-07-29 03:39:30 +03:00
initial
This commit is contained in:
30
sql/migrations/006_graph_sessions.sql
Normal file
30
sql/migrations/006_graph_sessions.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Graph session metrics (direct MariaDB ingest; no ETL).
|
||||
-- Run as root on existing servers: mysql -u root -p androidcast_crashes < sql/migrations/006_graph_sessions.sql
|
||||
|
||||
CREATE TABLE IF NOT EXISTS graph_sessions (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
session_id VARCHAR(96) NOT NULL,
|
||||
company_id INT UNSIGNED NOT NULL DEFAULT 1,
|
||||
user_id INT UNSIGNED NULL,
|
||||
device_id VARCHAR(128) NULL,
|
||||
app_version VARCHAR(64) NULL,
|
||||
sdk_int INT NULL,
|
||||
started_at_ms BIGINT NOT NULL,
|
||||
ended_at_ms BIGINT NOT NULL,
|
||||
duration_s INT NOT NULL,
|
||||
completed TINYINT(1) NOT NULL DEFAULT 1,
|
||||
direction ENUM('sender','receiver') NOT NULL DEFAULT 'sender',
|
||||
transport VARCHAR(24) NOT NULL DEFAULT 'wifi',
|
||||
avg_kbps INT NOT NULL DEFAULT 0,
|
||||
recv_kbps INT NOT NULL DEFAULT 0,
|
||||
packet_loss_pct DECIMAL(6,3) NOT NULL DEFAULT 0.0,
|
||||
ntp_source VARCHAR(32) NOT NULL DEFAULT 'device',
|
||||
ntp_correction_s INT NULL,
|
||||
install_source VARCHAR(32) NOT NULL DEFAULT 'direct',
|
||||
meta_json LONGTEXT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uq_graph_session_id (session_id),
|
||||
KEY idx_graph_company_time (company_id, started_at_ms),
|
||||
KEY idx_graph_device (device_id),
|
||||
KEY idx_graph_app_version (app_version)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
6
sql/migrations/006_graph_sessions.sqlite.sql
Normal file
6
sql/migrations/006_graph_sessions.sqlite.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- SQLite graph_sessions indexes (table may already exist via GraphRepository::ensureSchema).
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_company_time ON graph_sessions (company_id, started_at_ms);
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_user_time ON graph_sessions (user_id, started_at_ms);
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_started ON graph_sessions (started_at_ms);
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_device ON graph_sessions (device_id);
|
||||
5
sql/migrations/008_graph_sessions_indexes.sql
Normal file
5
sql/migrations/008_graph_sessions_indexes.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
-- Extra graph_sessions indexes for graphs dashboard (user scope + platform-wide time range).
|
||||
-- Idempotent on MariaDB 10.5+: duplicate index names are ignored manually when re-run.
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_user_time ON graph_sessions (user_id, started_at_ms);
|
||||
CREATE INDEX IF NOT EXISTS idx_graph_started ON graph_sessions (started_at_ms);
|
||||
Reference in New Issue
Block a user