-- =============================================
-- 自动标注任务支持多数据集类型迁移
-- 为 t_dm_auto_annotation_tasks 表添加 dataset_type 列
-- =============================================

USE datamate;
SET @db_name = DATABASE();

-- 添加 dataset_type 列（IMAGE/TEXT/AUDIO/VIDEO），已有记录默认为 IMAGE
SET @ddl = (
    SELECT IF(
        EXISTS(
            SELECT 1
            FROM information_schema.COLUMNS
            WHERE TABLE_SCHEMA = @db_name
              AND TABLE_NAME = 't_dm_auto_annotation_tasks'
              AND COLUMN_NAME = 'dataset_type'
        ),
        'SELECT ''skip: column dataset_type already exists''',
        'ALTER TABLE t_dm_auto_annotation_tasks ADD COLUMN dataset_type VARCHAR(50) NOT NULL DEFAULT ''IMAGE'' COMMENT ''数据集类型: IMAGE/TEXT/AUDIO/VIDEO'' AFTER dataset_name'
    )
);
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
