-- ============================================
-- 数据库结构更新脚本 (完整版)
-- 日期: 2025-12-03
-- 说明: 将存储Base64图片的字段从TEXT升级为LONGTEXT
-- ============================================

-- 选择数据库
USE aigc_platform;

-- ============================================
-- 1. storyboard_video_tasks 表 (分镜视频任务)
-- ============================================
ALTER TABLE storyboard_video_tasks MODIFY COLUMN image_url LONGTEXT;
ALTER TABLE storyboard_video_tasks MODIFY COLUMN result_url LONGTEXT;
ALTER TABLE storyboard_video_tasks MODIFY COLUMN storyboard_images LONGTEXT;
ALTER TABLE storyboard_video_tasks MODIFY COLUMN video_urls LONGTEXT;

-- ============================================
-- 2. user_works 表 (用户作品)
-- ============================================
ALTER TABLE user_works MODIFY COLUMN result_url LONGTEXT;
ALTER TABLE user_works MODIFY COLUMN thumbnail_url LONGTEXT;

-- ============================================
-- 3. image_to_video_tasks 表 (图生视频任务)
-- ============================================
ALTER TABLE image_to_video_tasks MODIFY COLUMN result_url LONGTEXT;

-- ============================================
-- 验证结果
-- ============================================
SELECT '=== 验证修改结果 ===' AS info;
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE 
FROM information_schema.COLUMNS 
WHERE TABLE_SCHEMA = 'aigc_platform' 
  AND COLUMN_NAME IN ('image_url', 'result_url', 'thumbnail_url', 'storyboard_images', 'video_urls')
  AND TABLE_NAME IN ('storyboard_video_tasks', 'user_works', 'image_to_video_tasks')
ORDER BY TABLE_NAME, COLUMN_NAME;
