CREATE TABLE IF NOT EXISTS group_chat_messages (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NULL,
    user_name VARCHAR(150) NULL,
    user_role VARCHAR(80) NULL,
    message TEXT NOT NULL,
    source VARCHAR(30) NOT NULL DEFAULT 'web',
    telegram_chat_id VARCHAR(80) NULL,
    telegram_message_id BIGINT NULL,
    telegram_from_id VARCHAR(80) NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_created_at (created_at),
    INDEX idx_source (source),
    INDEX idx_telegram_message_id (telegram_message_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
