-- Documents the `user_telegram` table used by the Telegram bot
-- (teacher_reminder_bot, sibling repo) to link a Telegram account to a
-- system user (teachers today, via db.py's save_telegram_id/get_linked_user).
--
-- This table has NO tracked schema anywhere — not in the bot repo, not
-- previously in this repo — it only exists, undocumented, in production.
-- Confirmed via `SHOW CREATE TABLE user_telegram` on the local dev DB:
-- ERROR 1146 (42S02): Table 'axioma.user_telegram' doesn't exist.
--
-- DO NOT run this against production — it already has this table.
-- This file exists so a fresh local dev DB has parity with it.

CREATE TABLE user_telegram (
    user_id      BIGINT UNSIGNED NOT NULL,
    telegram_id  BIGINT NOT NULL,
    created_at   TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uniq_user_telegram_user (user_id),
    UNIQUE KEY uniq_user_telegram_telegram (telegram_id),
    FOREIGN KEY (user_id) REFERENCES users(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
