From a67cf297df78521d1c2dee0dc2746a8046675b56 Mon Sep 17 00:00:00 2001
From: wikiapiserver
Date: Thu, 25 Jun 2026 21:37:16 +0200
Subject: chore: add SQL migration files for production schema

- sql/000_widen_tokens.sql: widen token columns to TEXT, add
  refresh_token_created and access_token_created timestamps
- sql/001_add_api_logs.sql: create api_logs table for request logging
---
 sql/001_add_api_logs.sql | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 sql/001_add_api_logs.sql

(limited to 'sql/001_add_api_logs.sql')

diff --git a/sql/001_add_api_logs.sql b/sql/001_add_api_logs.sql
new file mode 100644
index 0000000..44c5622
--- /dev/null
+++ b/sql/001_add_api_logs.sql
@@ -0,0 +1,14 @@
+-- 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;
-- 
cgit v1.2.3

