-- 创建学习会话表
CREATE TABLE IF NOT EXISTS ai_learning_sessions (
    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '会话ID',
    user_id BIGINT NOT NULL COMMENT '用户ID',
    book_id VARCHAR(36) NOT NULL COMMENT '词汇书ID',
    daily_goal INT DEFAULT 20 COMMENT '每日学习目标',
    new_words_count INT DEFAULT 0 COMMENT '新学单词数',
    review_count INT DEFAULT 0 COMMENT '复习单词数',
    mastered_count INT DEFAULT 0 COMMENT '掌握单词数',
    started_at TIMESTAMP NOT NULL COMMENT '开始时间',
    completed_at TIMESTAMP NULL COMMENT '完成时间',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    
    INDEX idx_user_book (user_id, book_id),
    INDEX idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='学习会话表';
