-- 迁移文件: 003_add_is_featured.sql
-- 描述: 为models表添加is_featured字段，用于标识精选模型
-- 需求: 首页推荐展示

-- ============================================
-- 正向迁移: 添加is_featured字段
-- ============================================

-- 添加is_featured字段，默认值为false
ALTER TABLE aigcspace.models ADD COLUMN IF NOT EXISTS is_featured BOOLEAN DEFAULT FALSE NOT NULL;

-- 添加字段注释
COMMENT ON COLUMN aigcspace.models.is_featured IS '是否为精选模型，用于首页推荐展示';

-- 创建is_featured字段索引（优化按精选状态筛选性能）
CREATE INDEX IF NOT EXISTS idx_models_is_featured ON aigcspace.models(is_featured);

-- ============================================
-- 回滚迁移: 删除is_featured字段
-- ============================================
-- DROP INDEX IF EXISTS aigcspace.idx_models_is_featured;
-- ALTER TABLE aigcspace.models DROP COLUMN IF EXISTS is_featured;
