-- Add api_logs table for tracking article API request failures.
-- Apply to the wikiapiserver database.

CREATE TABLE IF NOT EXISTS api_logs (
    id               INT NOT NULL AUTO_INCREMENT,
    created_at       TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    username         VARCHAR(255) NOT NULL,
    article_name     VARCHAR(512) NOT NULL,
    status_code      INT NOT NULL,
    response_time_ms  INT NOT NULL,
    error            TEXT DEFAULT NULL,
    request_url      TEXT NOT NULL,
    PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
