-- 数据库迁移脚本：添加完成时点数字段和COMPLETED状态
-- 执行时间：2025-08-27

-- 1. 添加 completed_points 字段
ALTER TABLE `link_task` 
ADD COLUMN `completed_points` int UNSIGNED NULL DEFAULT NULL COMMENT '完成时的点数' 
AFTER `first_region_select_at`;

-- 2. 修改 status 枚举，添加 COMPLETED 状态
ALTER TABLE `link_task` 
MODIFY COLUMN `status` enum('NEW','USING','LOGGED_IN','COMPLETED','REFUNDED','EXPIRED') 
CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'NEW';

-- 3. 验证修改结果
SELECT 
    COLUMN_NAME, 
    DATA_TYPE, 
    COLUMN_TYPE, 
    IS_NULLABLE, 
    COLUMN_DEFAULT, 
    COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = DATABASE() 
  AND TABLE_NAME = 'link_task' 
  AND COLUMN_NAME IN ('status', 'completed_points')
ORDER BY ORDINAL_POSITION;

-- 4. 检查表结构
SHOW CREATE TABLE `link_task`;
