-- ForexBot2 web dashboard schema (MySQL 8.0+ / MariaDB 10.5+) -- Load once: mysql -u root -p < schema.sql -- (edit the database/user names to taste; keep them in sync with config.php) CREATE DATABASE IF NOT EXISTS forexbot_web CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; USE forexbot_web; -- Latest tick per symbol — a single row upserted on every published tick -- (the bot throttles to 1/s). Tick history is deliberately NOT stored: -- XAU produces 100k+ ticks/day; add a separate append table with a purge -- job if charting is ever needed. CREATE TABLE IF NOT EXISTS live_price ( symbol VARCHAR(16) NOT NULL PRIMARY KEY, price DECIMAL(12,5) NOT NULL, prev_price DECIMAL(12,5) NULL, tick_at DATETIME NOT NULL, -- UTC, set by the bot updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB; -- One row per (symbol, timeframe, signal bar). Re-scans of the same bar -- (e.g. the bot's level-breach rescan) update the row in place, so the -- table is also a clean historical signal log (~400 rows/day for XAU on -- M5+M15+H1+H4 — no retention job needed). CREATE TABLE IF NOT EXISTS signal_reports ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, symbol VARCHAR(16) NOT NULL, timeframe VARCHAR(8) NOT NULL, -- '5min','15min','1h','4h' bar_ts DATETIME NOT NULL, -- signal bar timestamp (UTC) signal_name VARCHAR(12) NOT NULL, -- STRONG_BUY..STRONG_SELL quality VARCHAR(2) NOT NULL, -- A+, A, B, C, D, F score DECIMAL(6,2) NOT NULL, confidence DECIMAL(5,2) NOT NULL, payload JSON NOT NULL, -- full dashboard payload created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY uq_bar (symbol, timeframe, bar_ts), KEY idx_latest (symbol, timeframe, id) ) ENGINE=InnoDB; -- Dedicated app user with least privilege (adjust host/password!): -- CREATE USER 'forexbot'@'localhost' IDENTIFIED BY 'CHANGE-ME'; -- GRANT SELECT, INSERT, UPDATE ON forexbot_web.* TO 'forexbot'@'localhost'; -- FLUSH PRIVILEGES;