-- 数据库性能优化索引（完整修正版）

-- ==================== markdown_file 表索引 ====================
CREATE INDEX idx_markdown_grouping_id ON markdown_file(grouping_id);
CREATE INDEX idx_markdown_is_deleted ON markdown_file(is_deleted);
CREATE INDEX idx_markdown_created_at ON markdown_file(created_at);
CREATE INDEX idx_markdown_grouping_deleted ON markdown_file(grouping_id, is_deleted);

-- ==================== image 表索引 ====================
CREATE INDEX idx_image_markdown_id ON image(markdown_id);
CREATE INDEX idx_image_stored_name ON image(stored_name);
CREATE INDEX idx_image_created_at ON image(created_at);

-- ==================== grouping 表索引（注意反引号！）====================
CREATE INDEX idx_grouping_parent_id ON `grouping`(parentId);
CREATE INDEX idx_grouping_is_deleted ON `grouping`(is_deleted);

-- ==================== trash 表索引 ====================
CREATE INDEX idx_trash_user_id ON trash(user_id);
CREATE INDEX idx_trash_deleted_at ON trash(deleted_at);
CREATE INDEX idx_trash_item_type ON trash(item_type);

-- ==================== user 表索引 ====================
CREATE INDEX idx_user_username ON user(username);