-- 创建直播投流源表
CREATE TABLE IF NOT EXISTS `ai_live_streams` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `title` varchar(255) NOT NULL COMMENT '投流源标题',
  `platform` varchar(50) NOT NULL COMMENT '平台名称(如:抖音,快手,淘宝,京东,小红书等)',
  `stream_url` varchar(500) NOT NULL COMMENT '投流URL地址',
  `cover_image` varchar(500) DEFAULT NULL COMMENT '封面图片URL',
  `description` text COMMENT '描述信息',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
  `sort` int NOT NULL DEFAULT '0' COMMENT '排序值,数值越大越靠前',
  `view_count` int NOT NULL DEFAULT '0' COMMENT '观看次数',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束时间',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_platform` (`platform`),
  KEY `idx_status` (`status`),
  KEY `idx_sort` (`sort`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='直播投流源表';

ALTER TABLE `ai_live_streams` 
ADD UNIQUE INDEX `idx_platform_unique` (`platform`);