-- ============================================================================
-- 迁移脚本: 添加 ideal_life 字段到 t_user_profile 表
-- 日期: 2025-12-22
-- 描述: 为用户档案表添加理想生活状态字段
-- ============================================================================

-- 检查字段是否存在，不存在则添加
SET @dbname = DATABASE();
SET @tablename = 't_user_profile';
SET @columnname = 'ideal_life';
SET @preparedStatement = (SELECT IF(
    (
        SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_SCHEMA = @dbname
        AND TABLE_NAME = @tablename
        AND COLUMN_NAME = @columnname
    ) > 0,
    'SELECT 1',
    CONCAT('ALTER TABLE ', @tablename, ' ADD COLUMN ', @columnname, ' TEXT COMMENT ''理想生活状态'' AFTER future_vision')
));

PREPARE alterIfNotExists FROM @preparedStatement;
EXECUTE alterIfNotExists;
DEALLOCATE PREPARE alterIfNotExists;
