-- Migration: 0001_create_users_table
-- Phase 2 (Telegram Engine) — minimal user identity needed for /start
-- and menu routing. Academic-profile columns (major, university,
-- semester, etc.) are added in the Mini App integration phase via a
-- follow-up migration, to keep each migration focused and reviewable.

CREATE TABLE IF NOT EXISTS users (
    id                   BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    telegram_id          BIGINT UNSIGNED NOT NULL,
    username             VARCHAR(64)  NULL,
    first_name           VARCHAR(128) NULL,
    last_name            VARCHAR(128) NULL,
    is_profile_complete  TINYINT(1)   NOT NULL DEFAULT 0,
    created_at           DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at           DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

    UNIQUE KEY uq_users_telegram_id (telegram_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
