-- Run this once against your database before deploying the updated router.php.
-- Powers the get_api_usage_stats endpoint (Total Requests / Successful / Failed
-- on the API Keys dashboard page).

CREATE TABLE IF NOT EXISTS api_request_log (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    endpoint VARCHAR(64) NOT NULL,
    status ENUM('success','failed') NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_user_month (user_id, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
