-- 2020-07-06 10:00
-- 陪玩游戏配置表
ALTER TABLE `friendship`.`play_game_config`
MODIFY COLUMN `status` tinyint(2) NULL DEFAULT 0 COMMENT '状态' AFTER `create_time`;

-- 2020-07-06 10:00
-- 陪玩师注册表
ALTER TABLE `friendship`.`play_user_registered`
ADD COLUMN `service_total_num` int(10) NULL DEFAULT 0 COMMENT '服务人数' AFTER `game_cover`;

ALTER TABLE `friendship`.`play_user_registered`
ADD COLUMN `remark` varchar(128) NULL COMMENT '拒绝理由' AFTER `service_total_num`;

-- 2020-07-06 10:00
-- 陪玩师认证
ALTER TABLE `friendship`.`user`
ADD COLUMN `game_authenticate` tinyint(2) NULL COMMENT '陪玩认证' AFTER `home_img`;

-- 2020-07-07 20:13
ALTER TABLE `friendship`.`play_game_config`
ADD COLUMN `certification_picture_template` varchar(256) NULL COMMENT '技能认证示例图' AFTER `game_cover`;

-- 2020-07-08 19：00
ALTER TABLE `friendship`.`play_game_config`
ADD COLUMN `dictionary_id` bigint(20) NULL COMMENT '技能段位字典id' AFTER `game_name`;

-- 2020-07-08 20:13
-- 修改陪玩订单表
ALTER TABLE `friendship`.`play_orders`
ADD COLUMN `create_time` timestamp(0) NULL COMMENT '订单创建时间' AFTER `status`,
ADD COLUMN `receiving_order_time` timestamp(0) NULL COMMENT '接单时间' AFTER `create_time`,
ADD COLUMN `confirm_service_time` timestamp(0) NULL COMMENT '确认服务时间' AFTER `receiving_order_time`,
ADD COLUMN `start_service_time` timestamp(0) NULL COMMENT '开始服务时间' AFTER `confirm_service_time`,
ADD COLUMN `complete_service_time` timestamp(0) NULL COMMENT '完成服务时间' AFTER `start_service_time`;
ADD COLUMN `cancel_time` timestamp(0) NULL COMMENT '取消订单时间' AFTER `complete_service_time`;
ADD COLUMN `pay_time` timestamp(0) NULL COMMENT '支付时间' AFTER `cancel_time`;
ADD COLUMN `price` int(10) NULL COMMENT '每局的单价' AFTER `pay_time`;
ADD COLUMN `refuse_order_time` timestamp(0) NULL COMMENT '拒绝订单时间' AFTER `price`;

-- 2020-07-09
-- 增加系统配置
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`)
VALUES (10001024, '陪玩系统抽成', '0.2', '', '2020-07-09 10:50:48', '2020-07-09 10:50:51', 'PWXTCC');
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`)
VALUES (10001025, '陪玩每局游戏默认的U豆数', '30', NULL, '2020-07-09 16:06:04', '2020-07-09 16:06:06', 'PWMRYXYD');

-- 2020-07-09
-- 话题表增加推荐到首页的状态
ALTER TABLE `friendship`.`topic`
ADD COLUMN `recomand_status` tinyint(2)  DEFAULT NULL COMMENT '推荐到首页状态 0:已推荐,未推荐' AFTER `status`;

-- 2020-07-17
-- 动态点赞增加未读消息状态
ALTER TABLE `friendship`.`daily_dynamics_user`
ADD COLUMN `read_status` tinyint(2) NULL COMMENT '是否已读' AFTER `create_time`;

-- 2020-07-17
-- 声卡点赞增加未读消息状态
ALTER TABLE `friendship`.`user_like_miss`
ADD COLUMN `read_status` tinyint(2) NULL COMMENT '是否已读' AFTER `update_time`;

-- 2020-07-20
-- 用户信息表
update user set game_authenticate = 0 where game_authenticate is null;


-- 2020-07-20
-- 系统配置表
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`)
VALUES (10001026, '陪玩师默认的消息', '你好,需要游戏陪玩的可以直接发消息给我哦,我会尽快给你答复的,暂时不闲聊哈。', NULL, NULL, NULL, 'PWMRXX');


-- 2020-07-20
-- 配置默认审核状态
ALTER TABLE `friendship`.`play_user_registered`
MODIFY COLUMN `service_status` tinyint(2) NULL DEFAULT 0 COMMENT '服务状态(接单中/暂停接单)' AFTER `verify_status`;

-- 作品id 需要先清理数据
ALTER TABLE `friendship`.`user_like_miss`
DROP INDEX `idx_userid_workId`,
ADD UNIQUE INDEX `idx_userid_workId`(`user_id`, `works_id`) USING BTREE;



-- 用户收入表
ALTER TABLE `friendship`.`reward_detail`
CHANGE COLUMN `reward_user_id` `from_user_id` bigint(20) NULL DEFAULT NULL COMMENT '打赏/下单的用户id' AFTER `id`,
CHANGE COLUMN `receive_reward_user_id` `to_user_id` bigint(20) NULL DEFAULT NULL COMMENT '收到收入的用户id' AFTER `from_user_id`,
ADD COLUMN `type` tinyint(2) NULL COMMENT '收入类型' AFTER `receive_total_sugar`,
ADD COLUMN `des` varchar(16) NULL COMMENT '收入说明' AFTER `type`;
MODIFY COLUMN `type` tinyint(2) NULL DEFAULT 0 COMMENT '收入类型' AFTER `receive_total_sugar`;
ALTER  TABLE reward_detail RENAME TO user_income_detail;
update user_income_detail set type = 1,des = '游戏陪玩收入' where gift_name is null;
update user_income_detail set type = 0,des = '礼物打赏收入' where gift_name is not null;

-- 2020-07-25
-- 陪玩订单表
ALTER TABLE `friendship`.`play_orders`
ADD COLUMN `sugar` double(10, 2) NULL COMMENT 'Q糖' AFTER `refuse_order_time`,
ADD COLUMN `money` double(10, 2) NULL COMMENT '对应的金额' AFTER `sugar`;

-- 2020-07-27
-- 陪玩图片形象卡
ALTER TABLE `friendship`.`play_user_image_card_pictures`
ADD COLUMN `is_fill` tinyint(2) NULL COMMENT '是否拉伸' AFTER `update_time`,
ADD COLUMN `new_picture_src` varchar(300) NULL COMMENT '最新上传的图片url' AFTER `is_fill`;
ADD COLUMN `new_picture_src_is_fill` tinyint(2) NULL COMMENT '新上传的图片是否需要拉伸' AFTER `new_picture_src`;


-- 2020-07-27
-- 陪玩视频形象卡
ALTER TABLE `friendship`.`play_user_image_card_video`
ADD COLUMN `is_fill` tinyint(2) NULL COMMENT '是否拉伸' AFTER `update_time`,
ADD COLUMN `new_video_src` varchar(300) NULL COMMENT '新的视频url' AFTER `is_fill`,
ADD COLUMN `new_video_cover_src` varchar(300) NULL COMMENT '新的视频的封面' AFTER `new_video_src`;
ADD COLUMN `new_video_is_fill` tinyint(2) NULL COMMENT '新的视频是否需要拉伸' AFTER `new_video_cover_src`;
update `friendship`.`system_config` set `value` = '150',`update_time` = '2020-07-27 11:51:20' where id = '10001025';

INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`)
VALUES (10001027, '陪玩价格推荐价格', '150,300,500','价格之间用逗号隔开', NULL, NULL, 'PWTJXX');

-- 游戏技能配置增加计费方式
ALTER TABLE `friendship`.`play_game_config`
ADD COLUMN `billing_way` tinyint(2) NULL COMMENT '计费方式' AFTER `status`;

-- 更新收入表
update user_income_detail set type = 0,des = '礼物打赏收入' where type is null;

-- 陪玩图片形象卡
ALTER TABLE `friendship`.`play_user_image_card_pictures`
MODIFY COLUMN `is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '是否拉伸' AFTER `update_time`;

-- 陪玩形象卡推荐表
ALTER TABLE `friendship`.`play_image_card_recommend`
ADD COLUMN `is_fill_status` varchar(20) NULL COMMENT '拉伸状态' AFTER `des`;

-- 陪玩视频形象卡
ALTER TABLE `friendship`.`play_user_image_card_video`
MODIFY COLUMN `is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '是否拉伸' AFTER `update_time`;
MODIFY COLUMN `new_video_is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '新的视频是否需要拉伸' AFTER `new_video_cover_src`;

-- 交友形象卡图片
ALTER TABLE `friendship`.`user_image_card_pictures`
ADD COLUMN `is_fill` tinyint(2) NULL COMMENT '是否拉伸' AFTER `update_time`;
MODIFY COLUMN `is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '是否拉伸' AFTER `update_time`;

-- 交友形象卡视频
ALTER TABLE `friendship`.`user_image_card_video`
ADD COLUMN `is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '是否拉伸' AFTER `update_time`;

-- 形象卡推荐表
ALTER TABLE `friendship`.`image_card_recommand`
ADD COLUMN `is_fill` varchar(16) NULL COMMENT '推荐的拉伸状态' AFTER `logic_delete`;

-- 直播间
ALTER TABLE `friendship`.`live_room`
ADD UNIQUE INDEX `idx_userId`(`user_id`) USING BTREE COMMENT '用户id唯一索引';
ALTER TABLE `friendship`.`live_room`
ADD COLUMN `message_id` varchar(32) NOT NULL COMMENT '消息id' AFTER `create_time`;
ALTER TABLE `friendship`.`live_room`
ADD COLUMN `tag_id` varchar(32) NULL COMMENT '房间标签' AFTER `message_id`;
ALTER TABLE `friendship`.`live_room`
ADD COLUMN `type` tinyint(2) NULL COMMENT '房间类型' AFTER `tag_id`;
ALTER TABLE `friendship`.`live_room`
CHANGE COLUMN `create_time` `live_room_create_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间' AFTER `live_status`,
ADD COLUMN `live_room_close_time` timestamp(0) NULL COMMENT '直播间关闭时间' AFTER `type`;
ADD COLUMN `live_room_close_time` timestamp(0) NULL COMMENT '直播间关闭时间' AFTER `type`;
ALTER TABLE `friendship`.`live_room`
ADD COLUMN `accompany_chat_chat_sec` int(10) NULL COMMENT '陪聊房间陪聊时长设置' AFTER `live_room_close_time`,
ADD COLUMN `accompany_chat_gold_num` bigint(10) NULL COMMENT '陪聊金币' AFTER `accompany_chat_chat_sec`,
ADD COLUMN `back_pic_url` varchar(255) NULL COMMENT '背景图' AFTER `accompany_chat_gold_num`;
-- 修改group表名
ALTER  TABLE `friendship`.`group`
RENAME TO `topic_group`;

-- 账户详情表
ALTER  TABLE `friendship`.`user_account_detail`
ADD COLUMN `to_user_id` bigint(20) NULL COMMENT '收到收入的用户id' AFTER `user_id`,
ADD COLUMN `gift_id` bigint(20) NULL COMMENT '礼物id' AFTER `to_user_id`,
ADD COLUMN `type` tinyint(2) NULL COMMENT '类型' AFTER `des`;
