zjk
2026-09-29 54dcf0a82e7490fa58b1c056d5c0b9cb739c2931
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- 直播场次补充视频时长字段,兼容历史数据允许为空。
SET @duration_seconds_column_exists = (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'tcm_live_session'
    AND COLUMN_NAME = 'duration_seconds'
);
 
SET @duration_seconds_alter_sql = IF(
  @duration_seconds_column_exists = 0,
  'ALTER TABLE `tcm_live_session` ADD COLUMN `duration_seconds` INT DEFAULT NULL COMMENT ''视频时长(秒)'' AFTER `video_url`',
  'SELECT 1'
);
 
PREPARE duration_seconds_stmt FROM @duration_seconds_alter_sql;
EXECUTE duration_seconds_stmt;
DEALLOCATE PREPARE duration_seconds_stmt;