ALTER TABLE `friendship`.`user_friend`
DROP COLUMN `type`,
ADD COLUMN `type` tinyint(2) NULL COMMENT '类型' AFTER `status`;

CREATE TABLE `friendship`.`image_card_recommand`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `image_card_id` bigint(20) NULL DEFAULT NULL COMMENT '形象卡id',
  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
  `user_gender` tinyint(2) NULL DEFAULT NULL COMMENT '用户性别',
  `create_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11001010 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '形象卡推荐表' ROW_FORMAT = Dynamic;

--2020-03-16 10:00
ALTER TABLE `friendship`.`user_account`
ADD COLUMN `system_give_away_beans` integer(15) NULL COMMENT '系统赠送的u豆数' AFTER `update_time`;

-- 2020-03-16 15：10
ALTER TABLE `friendship`.`user_login`
ADD COLUMN `channel` varchar(32) NULL COMMENT '下载的渠道' AFTER `device_token`;

ALTER TABLE `friendship`.`user`
ADD COLUMN `channel` varchar(32) NULL COMMENT '下载的渠道' AFTER `device_token`;

ALTER TABLE `friendship`.`user_info`
ADD COLUMN `declaration` varchar(64) NULL COMMENT '交友宣言' AFTER `township`;

--2020-03-28 10：00
CREATE TABLE `friendship`.`Untitled`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `type` tinyint(2) NULL COMMENT '座驾类型',
  `beans` integer(10) NULL COMMENT '兑换的U豆',
  `level` integer(4) NULL COMMENT '财富登记',
  `oil_card` integer(4) NULL COMMENT '油卡',
  `car_url` varchar(300) NULL COMMENT '油卡url',
  `status` tinyint(2) NULL COMMENT '状态',
  PRIMARY KEY (`id`)
);

ALTER TABLE `friendship`.`car`
ADD COLUMN `create_time` timestamp(0) NULL COMMENT '创建时间' AFTER `status`;

CREATE TABLE `friendship`.`user_car_middle`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL COMMENT '用户id',
  `car_id` bigint(20) NULL COMMENT '座驾id',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 10001000;


CREATE TABLE `friendship`.`user_car`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `wealth_level` integer(10) NULL COMMENT '财富级别',
  `oil_card` integer(10) NULL COMMENT '我的油卡',
  `current_car_id` bigint(20) NULL COMMENT '驾驶中的座驾',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 10001000;

ALTER TABLE `friendship`.`car`
ADD COLUMN `default_car` tinyint(2) NULL DEFAULT 0 COMMENT '默认座驾' AFTER `create_time`;

ALTER TABLE `friendship`.`car`
CHANGE COLUMN `level` `wealth_level` int(4) NULL DEFAULT NULL COMMENT '财富等级' AFTER `beans`;

ALTER TABLE `friendship`.`user_car`
ADD COLUMN `user_id` bigint(20) NULL COMMENT '用户id' AFTER `current_car_id`,
ADD UNIQUE INDEX `userId`(`user_id`) USING BTREE;

-- 2020-03-30
CREATE TABLE `friendship`.`user_daily_receive_oilcard_detail`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL COMMENT '用户id',
  `oil_card` tinyint(10) NULL COMMENT '油卡数',
  `receive_date` timestamp(0) NULL COMMENT '领取日期',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 10001000;

ALTER TABLE `friendship`.`user_daily_receive_oilcard_detail` COMMENT = '用户油卡领取详情';

-- modify user_car
ALTER TABLE `friendship`.`user_car`
ADD COLUMN `user_improveInformation_receive_oilcard_status` tinyint(2) NULL COMMENT '完善个人信息领取油卡详情' AFTER `user_id`,
ADD COLUMN `user_publish_imagecard_status` tinyint(2) NULL COMMENT '用户发布形象卡领取油卡状态' AFTER `user_improveInformation_receive_oilcard_status`;

ALTER TABLE `friendship`.`user_car`
MODIFY COLUMN `user_improveInformation_receive_oilcard_status` tinyint(2) NULL DEFAULT 0 COMMENT '完善个人信息领取油卡详情' AFTER `user_id`,
MODIFY COLUMN `user_publish_imagecard_status` tinyint(2) NULL DEFAULT 0 COMMENT '用户发布形象卡领取油卡状态' AFTER `user_improveInformation_receive_oilcard_status`;

ALTER TABLE `friendship`.`user_car`
MODIFY COLUMN `wealth_level` int(10) NULL DEFAULT 1 COMMENT '财富级别' AFTER `id`;

ALTER TABLE `friendship`.`user_car`
ADD COLUMN `pickup_times` integer(6) NULL DEFAULT 0 COMMENT '每日油卡领取次数' AFTER `user_publish_imagecard_status`;

-- modify system-config
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`) VALUES (10001009, '每日领取的油卡', '100', NULL, '2020-03-30 14:57:41', NULL, 'MRLQYK');
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`) VALUES (10001010, '发布形象卡获取的油卡', '50', NULL, '2020-03-30 14:58:28', NULL, 'FBXXKHQYK');
INSERT INTO `friendship`.`system_config`(`id`, `name`, `value`, `des`, `create_time`, `update_time`, `sn`) VALUES (10001011, '完善基本信息获取油卡', '50', NULL, '2020-03-30 14:59:02', NULL, 'WSXXDYK');

-- modify user_car_middle 2020-04-02
ALTER TABLE `friendship`.`user_car_middle`
ADD COLUMN `create_time` timestamp(0) NULL COMMENT '创建时间' AFTER `car_id`;

-- 2020-04-02
CREATE TABLE `friendship`.`fatelink_history`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL COMMENT '用户id',
  `fatelink_user_id` bigint(20) NULL COMMENT '连接的用户id',
  `create_time` timestamp(0) NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 11001011;

ALTER TABLE `friendship`.`fatelink_history`
ADD UNIQUE INDEX `userIdMatchuserId`(`user_id`, `fatelink_user_id`) USING BTREE COMMENT '用户id和匹配到的用户id';

-- 2020-04-03
ALTER TABLE `friendship`.`car`
ADD COLUMN `car_name` varchar(16) NULL COMMENT '座驾名称' AFTER `default_car`;

ALTER TABLE `friendship`.`car`
DROP COLUMN `default_car`;

-- 2020-04-07
CREATE TABLE `friendship`.`chat_room`  (
  `id` bigint(20) NULL COMMENT '主键',
  `chat_room_user` varchar(40) NULL COMMENT '聊天室用户',
  `chat_room_id` varchar(50) NULL COMMENT '聊天室id',
  `create_time` timestamp(0) NULL COMMENT '创建时间',
  UNIQUE INDEX `userId`(`chat_room_user`(20)) USING BTREE COMMENT '用户id创建索引'
) ENGINE = InnoDB AUTO_INCREMENT = 10001000;

ALTER TABLE `friendship`.`chat_room` COMMENT = '聊天室详情表';

ALTER TABLE `friendship`.`user`
ADD COLUMN `user_identifier` varchar(64) NULL COMMENT '苹果id身份信息' AFTER `device_token`;

ALTER TABLE `friendship`.`user`
ADD COLUMN `full_name` varchar(32) NULL COMMENT '苹果的fullname' AFTER `user_identifier`;

ALTER TABLE `friendship`.`user`
DROP INDEX `idxIdPhone`,
DROP INDEX `useridx`,
ADD UNIQUE INDEX `idxIdPhone`(`id`, `phone`) USING BTREE,
ADD UNIQUE INDEX `useridx`(`id`) USING BTREE,
ADD UNIQUE INDEX `userIdentifier`(`user_identifier`(30)) USING BTREE;

-- 新增表2020-04-08
CREATE TABLE `friendship`.`report`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `report_user_id` bigint(20) NULL COMMENT '举报的用户id',
  `Reported_user_id` bigint(20) NULL COMMENT '被举报的用户id',
  `report_content` varchar(16) NULL COMMENT '举报内容',
  `create_time` datetime(0) NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL COMMENT '更新时间',
  `status` tinyint(2) NULL COMMENT '处理状态',
  `type` tinyint(2) NULL COMMENT '举报内容分类',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 11001001 COMMENT = '举报内容表';

-- 2020-04-08 9:44
CREATE TABLE `friendship`.`group`  (
  `id` bigint(20) NULL COMMENT '主键',
  `group_topic_id` varchar(40) NULL COMMENT '群聊关联话题id',
  `group_id` varchar(50) NULL COMMENT '群聊id',
  `create_time` timestamp(0) NULL COMMENT '创建时间',
  UNIQUE INDEX `topicId`(`group_topic_id`(20)) USING BTREE COMMENT '话题id创建索引'
) ENGINE = InnoDB AUTO_INCREMENT = 10010101;

ALTER TABLE `friendship`.`group` COMMENT = '群聊详情表';

-- 2020-04-08 17:52
CREATE TABLE `friendship`.`group_user`  (
  `id` bigint(20) NULL COMMENT '主键',
  `group_user` varchar(40) NULL COMMENT '群组用户',
  `group_id` varchar(50) NULL COMMENT '群组id',
  UNIQUE INDEX `userId`(`group_user`(20)) USING BTREE COMMENT '用户id创建索引'
) ENGINE = InnoDB AUTO_INCREMENT = 10011101;

ALTER TABLE `friendship`.`group_user` COMMENT = '群组用户中间表';

-- 2020-04-09 14:10
ALTER TABLE `friendship`.`topic`
ADD COLUMN `cover_img` varchar(255) NULL DEFAULT NULL COMMENT '背景图片地址' AFTER `status`;

-- 创建索引
ALTER TABLE `friendship`.`works`
ADD UNIQUE INDEX `userIdCreateTime`(`author_id`, `create_time`) USING BTREE;

ALTER TABLE `friendship`.`user_image_card_like_detail`
ADD UNIQUE INDEX `userIdAuthorId`(`user_id`, `image_card_author`) USING BTREE COMMENT '用户id和作者id';

ALTER TABLE `friendship`.`little_note`
MODIFY COLUMN `image_card_id` bigint(20) NULL DEFAULT NULL COMMENT '形象卡id' AFTER `user_id`,
ADD INDEX `image_card_id`(`image_card_id`) USING BTREE COMMENT '为形象卡id添加索引';

ALTER TABLE `friendship`.`user_image_card_pictures`
ADD UNIQUE INDEX `userIdSeq`(`user_id`, `seq`) USING BTREE COMMENT '用户id序号创建索引';

ALTER TABLE `friendship`.`works`
DROP INDEX `userIdCreateTime`,
ADD INDEX `userIdCreateTime`(`author_id`) USING BTREE;

ALTER TABLE `friendship`.`user_info`
ADD COLUMN `hobbies` varchar(64) NULL COMMENT '爱好' AFTER `declaration`,
ADD COLUMN `tags` varchar(64) NULL COMMENT '标签' AFTER `hobbies`;

ALTER TABLE `friendship`.`user_info`
ADD COLUMN `last_work_content` varchar(255) NULL COMMENT '最后一条作品的内容' AFTER `township`;

ALTER TABLE `friendship`.`image_card_recommand`
ADD COLUMN `oss_prefix` varchar(128) NULL COMMENT 'oss前缀' AFTER `create_time`,
ADD COLUMN `recommand_imagecard_urls` varchar(1024) NULL COMMENT '推荐列表' AFTER `oss_prefix`;

ALTER TABLE `friendship`.`image_card_recommand`
ADD COLUMN `video_cover_image` varchar(128) NULL COMMENT '视频封面' AFTER `recommand_imagecard_urls`;

-- 2020-04-11
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for user_device
-- ----------------------------
/*
 Navicat Premium Data Transfer

 Source Server         : 测试环境
 Source Server Type    : MySQL
 Source Server Version : 50721
 Source Host           : 120.79.211.173:3306
 Source Schema         : bore

 Target Server Type    : MySQL
 Target Server Version : 50721
 File Encoding         : 65001

 Date: 11/04/2020 11:21:01
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for user_device
-- ----------------------------
DROP TABLE IF EXISTS `user_device`;
CREATE TABLE `user_device` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '逻辑主键',
  `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户编号(用户未绑定则为0)',
  `device_id` varchar(64) NOT NULL COMMENT '设备唯一码',
  `idfa` varchar(64) DEFAULT NULL COMMENT '苹果IDFA(广告标识符)',
  `imei` varchar(64) DEFAULT NULL COMMENT '安卓IMEI',
  `oaid` varchar(64) DEFAULT NULL COMMENT '安卓OAID',
  `androidid` varchar(64) DEFAULT NULL COMMENT '安卓AndroidId',
  `ip` varchar(128) NOT NULL COMMENT '用户IP',
  `channel` varchar(64) NOT NULL COMMENT '下载渠道',
  `client` varchar(32) NOT NULL COMMENT '客户端',
  `advertiser` varchar(32) COMMENT '广告商',
  `advertiser_id` bigint(20) unsigned DEFAULT NULL COMMENT '广告商主键',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `device_id` (`device_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10000054 DEFAULT CHARSET=utf8mb4 COMMENT='内部设备唯一码表';

SET FOREIGN_KEY_CHECKS = 1;


-- 2020-04-10 11:03
DROP TABLE `friendship`.`topic_note`;

CREATE TABLE `friendship`.`private_note`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
  `create_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
  `content` varchar(300) NULL DEFAULT NULL COMMENT '内容',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11002121 COMMENT = '私人模式纸条表';

-- 2020-04-10 20:25
ALTER TABLE `friendship`.`topic_voice_barrage`
ADD COLUMN `is_private` tinyint(2) NULL DEFAULT 1 COMMENT '是否属于私人模式0:属于,1:不属于' AFTER `release_time`;

-- 2020-04-11 15:31
ALTER TABLE `friendship`.`group`
ADD COLUMN `group_name` varchar(120) NULL DEFAULT NULL COMMENT '群组名称' AFTER `group_id`;

-- 2020-04-13 9:45
ALTER TABLE `friendship`.`topic_voice_barrage`
MODIFY COLUMN `voice_duration` int(10) NULL DEFAULT NULL COMMENT '音轨长度' AFTER `voice_url`;
-- 2020-04-13 12:00 修改作品文案表
ALTER TABLE `friendship`.`work_template`
DROP COLUMN `dic_item_id`,
DROP COLUMN `title`,
DROP COLUMN `author`;

-- 2020-04-13 16:00 修改作品表
ALTER TABLE `friendship`.`works`
CHANGE COLUMN `title` `picture_url` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '背景图片地址' AFTER `author_id`;

-- 2020-04-13 16:00 修改用户信息表
ALTER TABLE `friendship`.`user_info`
DROP COLUMN `last_work_content`;

--2020-04-13 17：00
ALTER TABLE `friendship`.`report`
CHANGE COLUMN `Reported_user_id` `Reported_id` bigint(20) NULL DEFAULT NULL COMMENT '被举报的id' AFTER `report_user_id`;
MODIFY COLUMN `voice_duration` int(10) NULL DEFAULT NULL COMMENT '音轨长度（秒）' AFTER `voice_url`;

-- 2020-04-13 15:07
CREATE TABLE `friendship`.`user_thumb_topic_voice_barrage` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NOT NULL COMMENT '点赞用户id',
  `thumb_voice_barrage_id` bigint(20) DEFAULT NULL COMMENT '点赞的语音弹幕id',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10022021 DEFAULT CHARSET=utf8mb4 COMMENT='用户点赞话题中语音弹幕表';
ALTER TABLE `friendship`.`report` CHANGE COLUMN
 `Reported_user_id` `Reported_id` bigint(20) NULL DEFAULT NULL COMMENT '被举报的id' AFTER `report_user_id`;

-- 2020-04-14 14:41
create table `friendship`.`topic_mood_skin`(
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `mood_skin_url` varchar(128) NULL DEFAULT NULL COMMENT '心情皮肤地址',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10102021 DEFAULT CHARSET=utf8mb4 COMMENT='心情皮肤';

-- 2020-04-15 10:26
ALTER TABLE `friendship`.`topic_voice_barrage`
ADD COLUMN `mood_skin_id` bigint(20) NULL DEFAULT NULL COMMENT '心情皮肤' AFTER `topic_id`;

ALTER TABLE `friendship`.`user_thumb_topic_voice_barrage`
ADD COLUMN `status` tinyint(2) NULL DEFAULT 0 COMMENT '点赞状态0:点赞，1：取消点赞' AFTER `thumb_voice_barrage_id`;

-- 2020-04-16 15:33
create table `friendship`.`user_collect_topic`(
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
  `topic_id` bigint(20) NULL DEFAULT NULL COMMENT '话题id',
  `status` tinyint(2) NULL DEFAULT 0 COMMENT '收藏状态0:收藏，1：取消收藏',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10121121 DEFAULT CHARSET=utf8mb4 COMMENT='用户收藏话题表';

ADD COLUMN `status` tinyint(2) NULL DEFAULT 0 COMMENT '点赞状态0:点赞，1：取消点赞' AFTER `topic_id`;

-- 2020-04-26 11：20
ALTER TABLE `friendship`.`user_like_miss`
ADD INDEX `worksId`(`works_id`) USING BTREE COMMENT '作品id添加索引';

ALTER TABLE `friendship`.`user_like_miss`
DROP INDEX `worksId`,
ADD INDEX `worksId`(`works_id`, `type`) USING BTREE COMMENT '作品id添加索引';

-- 2020-04-16 ：16：30 创建融云消息记录表
CREATE TABLE `friendship`.`rong_chat_history`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `from_user_id` bigint(10) NULL COMMENT '发送人',
  `to_user_id` bigint(10) NULL COMMENT '收到消息的用户id,如果是群聊那么保存',
  `content` varchar(255) NULL COMMENT '消息内容',
  `msg_UID` varchar(32) NULL COMMENT '消息唯一id',
  `source` varchar(16) NULL COMMENT '来源',
  `sensitive_type` tinyint(2) NULL COMMENT '敏感词信息',
  `object_name` varchar(16) NULL COMMENT '消息类型',
  `channel_type` varchar(16) NULL COMMENT '会话类型',
  `group_user_id` bigint(10) NULL COMMENT '群组id',
  `create_time` timestamp(0) NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE INDEX `fromUserContentCreateTime`(`from_user_id`, `content`(15), `create_time`) USING BTREE COMMENT '发送者内容和时间做唯一索引'
) COMMENT = '融云聊天记录表';

ALTER TABLE `friendship`.`rong_chat_history`
ADD COLUMN `rong_id` varchar(32) NULL COMMENT '聊天室/群聊的房间id' AFTER `create_time`;

ALTER TABLE `friendship`.`rong_chat_history`
DROP INDEX `fromUserContentCreateTime`,
ADD INDEX `fromUserContentCreateTime`(`from_user_id`, `content`(15), `create_time`) USING BTREE COMMENT '发送者内容和时间做唯一索引';


-- 2020 04-17
ALTER TABLE `friendship`.`user_info`
DROP COLUMN `declaration`;

ALTER TABLE `friendship`.`fatelink_history`
ADD COLUMN `chat_room_id` varchar(32) NULL COMMENT '聊天室id' AFTER `create_time`;

ALTER TABLE `friendship`.`user_car`
ADD COLUMN `first_fatelink` tinyint(2) NULL COMMENT '是否首次连接' AFTER `pickup_times`;
update user_car set first_fatelink = 0;

-- 2020 04-18
CREATE TABLE `friendship`.`user_private_topic_background_picture`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(10) NULL COMMENT '用户id',
  `bgpicture_id` bigint(10) NULL COMMENT '背景图片id',
  PRIMARY KEY (`id`)
)ENGINE=InnoDB AUTO_INCREMENT=10211021 DEFAULT CHARSET=utf8mb4  COMMENT = '私人模式背景图片关系表';

ALTER TABLE `friendship`.`user_private_topic_background_picture`
ADD INDEX `user_id`(`user_id`) USING BTREE COMMENT '为用户id添加索引';

-- 2020-04-20 18：00
ALTER TABLE `friendship`.`user_image_card`
DROP COLUMN `is_fill`,
ADD COLUMN `is_fill` tinyint(2) NULL DEFAULT 0 COMMENT '视频是否撑满全屏' AFTER `update_time`;

-- 2020 -4-20 23：30
ALTER TABLE `friendship`.`image_card_recommand`
ADD UNIQUE INDEX `imagecardUserId`(`image_card_id`, `user_id`) USING BTREE COMMENT '形象卡用户id索引';

ALTER TABLE `friendship`.`user_image_card_like_detail`
DROP INDEX `userIdAuthorId`,
ADD UNIQUE INDEX `userIdAuthorIdimageCardId`(`user_id`, `image_card_author`, `image_card_id`) USING BTREE COMMENT '用户id和作者id';

ALTER TABLE `friendship`.`user_ios_subscription_receipt`
MODIFY COLUMN `receipt` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '票据' AFTER `id`;

ALTER TABLE `friendship`.`orders`
ADD UNIQUE INDEX `payNo`(`pay_no`(20)) USING BTREE;

ALTER TABLE `friendship`.`user_subscription_detail`
ADD UNIQUE INDEX `originalTransactionalId`(`original_transaction_id`(10)) USING BTREE COMMENT '原始票据唯一索引';


-- 2020-04-24 16：00
ALTER TABLE `friendship`.`rong_chat_history`
ADD COLUMN `current_status` tinyint(2) NULL DEFAULT 1 COMMENT '最新一次聊天记录状态' AFTER `rong_id`;

--  2020 -04- 25 9:21
ALTER TABLE `friendship`.`user`
DROP COLUMN `home_img`,
ADD COLUMN `live_status` tinyint(2) NULL DEFAULT 0 COMMENT '直播状态' AFTER `full_name`,
ADD COLUMN `has_lived` tinyint(2) NULL DEFAULT 0 COMMENT '是否直播过' AFTER `live_status`;

CREATE TABLE `friendship`.`user_live_queue_receive`  (
  `id` bigint(12) NULL COMMENT '主键',
  `user_id` bigint(20) NULL COMMENT '用户id',
  `message_id` varchar(32) NULL COMMENT '消息id',
  `create_time` timestamp(0) NULL COMMENT '创建时间',
  UNIQUE INDEX `userIdMessageId`(`user_id`, `message_id`) USING BTREE COMMENT '用户id与消息id唯一'
);

ALTER TABLE `friendship`.`user_live_queue_receive`
MODIFY COLUMN `id` bigint(12) NOT NULL AUTO_INCREMENT COMMENT '主键' FIRST,
ADD PRIMARY KEY (`id`);

-- 2020-04-25 14：50
CREATE TABLE `friendship`.`person_topic_salutation`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `salutation` varchar(300) NULL COMMENT '问候语',
  PRIMARY KEY (`id`) USING BTREE
)ENGINE = InnoDB AUTO_INCREMENT = 10011231 DEFAULT CHARSET=utf8mb4 COMMENT = '个人模式问候语';

-- 2020-04-26 10：30
ALTER TABLE `friendship`.`bosom_detail`
ADD UNIQUE INDEX `userIdTargetId`(`user_id`, `target_user_id`) USING BTREE COMMENT '用户和目标用户只能存在一个';

ALTER TABLE `friendship`.`reward_detail`
ADD INDEX `receiveUserIdGiftIdCreateTIme`(`receive_reward_user_id`, `gift_id`, `create_time`) USING BTREE;


-- 2020-04-27 18：30
CREATE TABLE `friendship`.`user_last_reviewd_imagecard`  (
  `id` bigint(10) NOT NULL COMMENT 'id主键',
  `userId` bigint(20) NULL COMMENT '用户id',
  `last_verify_imagecard_pic` varchar(255) NULL COMMENT '最新审核通过的图片/视频封面的url',
  PRIMARY KEY (`id`),
  UNIQUE INDEX `userIdlastImageCardUrl`(`userId`, `last_verify_imagecard_pic`(10)) USING BTREE COMMENT '用户id和形象卡封面链接'
);

ALTER TABLE `friendship`.`user_last_reviewd_imagecard` COMMENT = '用户最新审核通过的形象卡封面';

-- 2020-04-27 17：00
INSERT INTO `friendship`.`person_topic_salutation`(`id`, `salutation`) VALUES (10001011, '忙碌了一天的你，想对自己说些什么呢？');

-- 2020-04-28 17：30
ALTER TABLE `friendship`.`user_subscription_detail`
ADD COLUMN `transaction_id` varchar(32) NULL COMMENT '票据id' AFTER `original_transaction_id`;

ALTER TABLE `friendship`.`user_subscription_detail`
ADD COLUMN `auto_renew_change_time` timestamp(0) NULL COMMENT '订阅发生变化的时间' AFTER `auto_renew_product_id`;

-- 2020-04-28 14：30
ALTER TABLE `friendship`.`orders`
DROP INDEX `payNo`,
ADD UNIQUE INDEX `payNo`(`pay_no`(32)) USING BTREE;

-- 2020-05-02 14:00
alter table `group`
drop index topicId,
add index topicId (group_topic_id);

alter table `group_user`
drop index userId,
add index userId (group_user);

-- 2020-05-07 12:00
drop table `user_package`

ALTER TABLE `friendship`.`rong_chat_history`
DROP INDEX `fromUserContentCreateTime`,
ADD INDEX `fromUserContentCreateTime`(`from_user_id`, `content`(15), `create_time`) USING BTREE COMMENT '发送者内容和时间做唯一索引';


-- 2020-05-08 12：00
ALTER TABLE `friendship`.`user_account_with_draw_detail`
MODIFY COLUMN `with_draw_amount` double(20, 2) NULL DEFAULT NULL COMMENT '提现金额' AFTER `user_card_id`;

ALTER TABLE `friendship`.`rong_chat_history`
MODIFY COLUMN `to_user_id` varchar(32) NULL DEFAULT NULL COMMENT '收到消息的用户id,如果是群聊那么保存' AFTER `from_user_id`;


-- 2020-05-14 7：43
ALTER TABLE `group`
MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键' FIRST,
ADD PRIMARY KEY ( `id` );

ALTER TABLE `group_user`
MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键' FIRST,
ADD PRIMARY KEY ( `id` );

-- 2020-05-19 10:17
CREATE TABLE `friendship`.`user_address_book`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
  `name` varchar(32) NULL DEFAULT NULL COMMENT '在通讯录中的昵称',
  `phone` varchar(16) NULL DEFAULT NULL COMMENT '手机号码',
  `is_exist` tinyint(2) NULL DEFAULT 0 COMMENT '存在用户通讯录状态0:存在，1：已被删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10111221 COMMENT = '用户通讯录信息表';