-- 创建数据统计模块所需的数据库索引
-- 用于优化统计查询性能

-- User表索引
CREATE INDEX IF NOT EXISTS idx_users_created_at ON aigcspace.users(created_at);

-- UserRechargeRecord表索引
CREATE INDEX IF NOT EXISTS idx_user_recharge_record_created_at ON aigcspace.user_recharge_record(created_at);
CREATE INDEX IF NOT EXISTS idx_user_recharge_record_status ON aigcspace.user_recharge_record(status);

-- BalanceLog表索引
CREATE INDEX IF NOT EXISTS idx_balance_log_user_created ON aigcspace.balance_log(user_id, created_at);
CREATE INDEX IF NOT EXISTS idx_balance_log_biz_type ON aigcspace.balance_log(biz_type);
CREATE INDEX IF NOT EXISTS idx_balance_log_created_at ON aigcspace.balance_log(created_at);

-- AIConversation表索引
CREATE INDEX IF NOT EXISTS idx_ai_conversation_created_at ON aigcspace.ai_conversation(created_at);

-- AIPicture表索引
CREATE INDEX IF NOT EXISTS idx_ai_picture_created_at ON aigcspace.ai_picture(created_at);
CREATE INDEX IF NOT EXISTS idx_ai_picture_model_name ON aigcspace.ai_picture(model_name);

-- AIVideo表索引
CREATE INDEX IF NOT EXISTS idx_ai_video_created_at ON aigcspace.ai_video(created_at);

-- AudioSynthesis表索引
CREATE INDEX IF NOT EXISTS idx_audio_synthesis_created_at ON aigcspace.audio_synthesis(created_at);

-- ASRRecognition表索引
CREATE INDEX IF NOT EXISTS idx_asr_recognition_created_at ON aigcspace.asr_recognition(created_at);

-- ASRTask表索引
CREATE INDEX IF NOT EXISTS idx_asr_task_created_at ON aigcspace.asr_task(created_at);

-- VoiceClone表索引
CREATE INDEX IF NOT EXISTS idx_voice_clone_created_at ON aigcspace.voice_clone(created_at);
