------------------
create table t_video_file_temp
(
video_id bigint not null comment ‘视频Id‘,
file_md5 varchar(64) comment ‘视频md5‘,
file_size bigint comment ‘视频大小‘,
source_url varchar(500) comment ‘视频源地址‘,
file_url varchar(500) comment ‘视频本地地址‘,
status tinyint(2) default 0 comment ‘0待审核,1待采集,2采集中,3采集成功,4采集失败,5上传服务器并转码成功‘,
check_time timestamp comment ‘审核时间‘,
origin tinyint(3) comment ‘来源‘,
source_id varchar(50) comment ‘来源Id‘,
download_time timestamp comment ‘下载时间‘,
service_ip varchar(50) comment ‘下载服务器标识‘,
repeat_id bigint comment ‘重复Id‘,
repeat_status tinyint(1) default 0 comment ‘0未检测,1重复,2不重复‘,
source_img_url varchar(500) comment ‘图片源url‘,
img_url varchar(500) comment ‘图片地址‘,
primary key (video_id)
);
------------------
1-导入SQL文件
2-建表,执行SQL 。
INSERT INTO `t_video_file_temp`(`video_id`,`file_md5`,`file_size`,`source_url`,`file_url`,`status`,`check_time`,`origin`,`source_id`,`download_time`,`service_ip`,`repeat_id`,`repeat_status`,`source_img_url`,`img_url`)
SELECT v.video_id,f.file_md5 ,f.file_size,f.source_url,f.file_url,f.status,f.check_time,f.origin, ext.source_id ,f.download_time,f.service_ip,f.repeat_id,f.repeat_status,img.source_url,f.file_url
FROM t_video v
JOIN t_video_file AS f ON f.file_id = v.video_file_id
JOIN t_video_ext ext ON ext.video_id = v.video_id
LEFT JOIN t_video_file AS img ON v.img_file_id=img.file_id;
-- t_video状态为4的改为2
update t_video t set t.status = 2 where t.status = 4;
-- 增加字段,审核用户名,是否删除,删除用户名,删除时间
ALTER TABLE `t_video` ADD COLUMN `user_name` varchar(50) ;
ALTER TABLE `t_video` ADD COLUMN `is_delete` tinyint(1) default 0 comment ‘1删除‘ ;
ALTER TABLE `t_video` ADD COLUMN `delete_user_name` varchar(50) ;
ALTER TABLE `t_video` ADD COLUMN `delete_time` timestamp NULL default NULL ;
-- 删除主外键,
ALTER TABLE `t_video` DROP FOREIGN KEY `FK_Reference_2`;
ALTER TABLE `t_video` DROP FOREIGN KEY `FK_Reference_3`;
-- 删除视频文件ID ,封面图片ID
alter table `t_video` drop column `img_file_id` ;
alter table `t_video` drop column `video_file_id` ;
alter table `t_video` drop column `userId` ;
-- 修改t_video_file名称 如:t_video_file_qaz 。还原t_video_file_temp表名
alter table t_video_file rename t_video_file_qaz ;
alter table t_video_file_temp rename t_video_file ;
-- t_video_ext 增加字段 发布时间
ALTER TABLE `t_video_ext` ADD COLUMN `release_time` timestamp NULL default NULL ;
-- ---------------------------------------
ALTER TABLE `t_video`
MODIFY COLUMN `video_id` bigint(20) NOT NULL AUTO_INCREMENT FIRST ;
ALTER TABLE `t_video_ext`
MODIFY COLUMN `classification` varchar(30) NULL DEFAULT NULL COMMENT ‘1搞笑,2美食,3,动物圈,4运动,5鬼畜调教,6美妆,7服饰,8健身,9资讯,10明星,11Korea相关,12电影相关,13电视剧‘ AFTER `source_url`;
-- 增加外键
ALTER TABLE `t_video_ext` ADD CONSTRAINT `FK_Reference_1` FOREIGN KEY (`video_id`) REFERENCES `t_video` (`video_id`);
-- 增加外键
ALTER TABLE `t_video_file` ADD CONSTRAINT `FK_Reference_5` FOREIGN KEY (`video_id`) REFERENCES `t_video` (`video_id`);