/*
SQLyog Trial v13.1.8 (64 bit)
MySQL - 8.0.33 : Database - tmerclub_im
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tmerclub_im` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `tmerclub_im`;

/*Table structure for table `im_msg_biz_employee_recent` */

DROP TABLE IF EXISTS `im_msg_biz_employee_recent`;

CREATE TABLE `im_msg_biz_employee_recent` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `send_type` tinyint DEFAULT NULL COMMENT '发送类型1平台2商家',
  `biz_id` bigint DEFAULT NULL COMMENT '平台或商家id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `employee_id` bigint DEFAULT NULL COMMENT '员工id',
  `employee_unread_num` int DEFAULT NULL COMMENT '员工未读条数',
  PRIMARY KEY (`id`),
  KEY `employee_user_idx`(`employee_id`, `user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='员工最近聊天记录表';

/*Table structure for table `im_msg_biz_user` */

DROP TABLE IF EXISTS `im_msg_biz_user`;

CREATE TABLE `im_msg_biz_user` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `send_type` tinyint DEFAULT NULL COMMENT '发送类型1平台2商家',
  `biz_id` bigint DEFAULT NULL COMMENT '平台或商家id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `employee_id` bigint DEFAULT NULL COMMENT '员工id',
  `biz_unread_num` int DEFAULT NULL COMMENT '平台或商家未读条数',
  `user_unread_num` int DEFAULT NULL COMMENT '用户未读条数',
  `last_msg_id` bigint DEFAULT NULL COMMENT '最后一条消息id',
  `last_msg_type` tinyint DEFAULT NULL COMMENT '最后一条消息类型,0文字1商品信息2图片',
  `last_msg_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '最后一条消息内容',
  `last_msg_who_send` tinyint DEFAULT NULL COMMENT '最后一条消息谁发的0系统1员工2用户',
  `last_msg_time` datetime DEFAULT NULL COMMENT '最后一条消息时间',
  PRIMARY KEY (`id`),
  KEY `employee_user_idx`(`employee_id`, `user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户最近聊天记录表';

/*Table structure for table `im_msg_biz_user_history` */

DROP TABLE IF EXISTS `im_msg_biz_user_history`;

CREATE TABLE `im_msg_biz_user_history` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `im_msg_biz_user_id` bigint DEFAULT NULL COMMENT '聊天对象id',
  `send_type` tinyint DEFAULT NULL COMMENT '发送类型1平台2商家',
  `biz_id` bigint DEFAULT NULL COMMENT '平台或商家id',
  `user_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户id',
  `employee_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '员工id',
  `type` tinyint DEFAULT NULL COMMENT '消息类型,0文字1商品信息2图片',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '消息内容',
  `who_send` tinyint DEFAULT NULL COMMENT '消息谁发的0系统1员工2用户',
  `user_unread` tinyint DEFAULT NULL COMMENT '用户是否已读',
  `employee_unread` tinyint DEFAULT NULL COMMENT '员工是否已读',
  `read_range` tinyint NOT NULL DEFAULT '0' COMMENT '可见权限：0.所有人可见  1.仅自己可见',
  PRIMARY KEY (`id`),
  KEY `employee_user_idx`(`employee_id`, `user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='店铺和用户历史聊天记录表';

/*Table structure for table `im_msg_biz_skills` */

DROP TABLE IF EXISTS `im_msg_biz_skills`;

CREATE TABLE `im_msg_biz_skills` (
                                     `id` bigint NOT NULL AUTO_INCREMENT COMMENT '客服自动回复id',
                                     `shop_id` bigint NOT NULL COMMENT '店铺id',
                                     `keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关键字',
                                     `content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '回复内容',
                                     `status` int DEFAULT NULL COMMENT '状态',
                                     `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
                                     `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                     `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                     PRIMARY KEY (`id`),
                                     KEY `shop_idx`(`shop_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='客服自动回复表';

/*Table structure for table `undo_log` */

DROP TABLE IF EXISTS `undo_log`;

CREATE TABLE `undo_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `branch_id` bigint NOT NULL,
  `xid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `context` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `undo_log` */

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
