# Copyright 2019 TeamTalk Remix Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: teamtalk-ng-db-ttopen
  labels:
    app: teamtalk-ng
    component: db
data:
  ttopen.sql: |
    # ************************************************************
    # Sequel Pro SQL dump
    # Version 4096
    #
    # http://www.sequelpro.com/
    # http://code.google.com/p/sequel-pro/
    #
    # Host: 10.11.2.38 (MySQL 5.6.16-64.2-56-log)
    # Database: ttopen
    # Generation Time: 2015-03-24 09:32:39 +0000
    # ************************************************************


    # Dump of table IMAdmin
    # ------------------------------------------------------------

    DROP DATABASE IF EXISTS teamtalk;
    CREATE DATABASE teamtalk DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    USE teamtalk;


    DROP TABLE IF EXISTS `IMAdmin`;

    CREATE TABLE `IMAdmin` (
      `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
      `uname` varchar(40) NOT NULL COMMENT '用户名',
      `pwd` char(32) NOT NULL COMMENT '密码',
      `status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '用户状态 0 :正常 1:删除 可扩展',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间´',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间´',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    LOCK TABLES `IMAdmin` WRITE;
    /*!40000 ALTER TABLE `IMAdmin` DISABLE KEYS */;

    INSERT INTO `IMAdmin` (`id`, `uname`, `pwd`, `status`, `created`, `updated`)
    VALUES
      (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,0,0);

    /*!40000 ALTER TABLE `IMAdmin` ENABLE KEYS */;
    UNLOCK TABLES;


    # Dump of table IMAudio
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMAudio`;

    CREATE TABLE `IMAudio` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `fromId` int(11) unsigned NOT NULL COMMENT '发送者Id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收者Id',
      `path` varchar(255) COLLATE utf8mb4_bin DEFAULT '' COMMENT '语音存储的地址',
      `size` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小',
      `duration` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '语音时长',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_fromId_toId` (`fromId`,`toId`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


    # Dump of table IMDepart
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMDepart`;

    CREATE TABLE `IMDepart` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '部门id',
      `departName` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '部门名称',
      `priority` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '显示优先级',
      `parentId` int(11) unsigned NOT NULL COMMENT '上级部门id',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '状态',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      PRIMARY KEY (`id`),
      KEY `idx_departName` (`departName`),
      KEY `idx_priority_status` (`priority`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;



    # Dump of table IMDiscovery
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMDiscovery`;

    CREATE TABLE `IMDiscovery` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
      `itemName` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '名称',
      `itemUrl` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'URL',
      `itemPriority` int(11) unsigned NOT NULL COMMENT '显示优先级',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '状态',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      PRIMARY KEY (`id`),
      KEY `idx_itemName` (`itemName`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


    # Dump of table IMGroup
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroup`;

    CREATE TABLE `IMGroup` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(256) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '群名称',
      `avatar` varchar(256) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '群头像',
      `creator` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建者用户id',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '群组类型，1-固定;2-临时群',
      `userCnt` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '成员人数',
      `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '是否删除,0-正常，1-删除',
      `version` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '群版本号',
      `lastChated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后聊天时间',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_name` (`name`(191)),
      KEY `idx_creator` (`creator`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群信息';


    # Dump of table IMGroupMember
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMember`;

    CREATE TABLE `IMGroupMember` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '群Id',
      `userId` int(11) unsigned NOT NULL COMMENT '用户id',
      `status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '是否退出群，0-正常，1-已退出',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_userId_status` (`groupId`,`userId`,`status`),
      KEY `idx_userId_status_updated` (`userId`,`status`,`updated`),
      KEY `idx_groupId_updated` (`groupId`,`updated`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和群的关系表';


    # Dump of table IMGroupMessage_0
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_0`;

    CREATE TABLE `IMGroupMessage_0` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';



    # Dump of table IMGroupMessage_1
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_1`;

    CREATE TABLE `IMGroupMessage_1` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';


    # Dump of table IMGroupMessage_2
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_2`;

    CREATE TABLE `IMGroupMessage_2` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';


    # Dump of table IMGroupMessage_3
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_3`;

    CREATE TABLE `IMGroupMessage_3` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';


    # Dump of table IMGroupMessage_4
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_4`;

    CREATE TABLE `IMGroupMessage_4` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';


    # Dump of table IMGroupMessage_5
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_5`;

    CREATE TABLE `IMGroupMessage_5` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';


    # Dump of table IMGroupMessage_6
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_6`;

    CREATE TABLE `IMGroupMessage_6` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';



    # Dump of table IMGroupMessage_7
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMGroupMessage_7`;

    CREATE TABLE `IMGroupMessage_7` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `groupId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `userId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '消息内容',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '2' COMMENT '群消息类型,101为群语音,2为文本',
      `status` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息状态',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_groupId_status_created` (`groupId`,`status`,`created`),
      KEY `idx_groupId_msgId_status_created` (`groupId`,`msgId`,`status`,`created`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='IM群消息表';



    # Dump of table IMMessage_0
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_0`;

    CREATE TABLE `IMMessage_0` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


    # Dump of table IMMessage_1
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_1`;

    CREATE TABLE `IMMessage_1` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;



    # Dump of table IMMessage_2
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_2`;

    CREATE TABLE `IMMessage_2` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


    # Dump of table IMMessage_3
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_3`;

    CREATE TABLE `IMMessage_3` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

    # Dump of table IMMessage_4
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_4`;

    CREATE TABLE `IMMessage_4` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


    # Dump of table IMMessage_5
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_5`;

    CREATE TABLE `IMMessage_5` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

    # Dump of table IMMessage_6
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_6`;

    CREATE TABLE `IMMessage_6` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

    # Dump of table IMMessage_7
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMMessage_7`;

    CREATE TABLE `IMMessage_7` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `relateId` int(11) unsigned NOT NULL COMMENT '用户的关系id',
      `fromId` int(11) unsigned NOT NULL COMMENT '发送用户的id',
      `toId` int(11) unsigned NOT NULL COMMENT '接收用户的id',
      `msgId` int(11) unsigned NOT NULL COMMENT '消息ID',
      `content` varchar(4096) COLLATE utf8mb4_bin DEFAULT '' COMMENT '消息内容',
      `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '消息类型',
      `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0正常 1被删除',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      PRIMARY KEY (`id`),
      KEY `idx_relateId_status_created` (`relateId`,`status`,`created`),
      KEY `idx_relateId_status_msgId_created` (`relateId`,`status`,`msgId`,`created`),
      KEY `idx_fromId_toId_created` (`fromId`,`toId`,`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

    # Dump of table IMRecentSession
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMRecentSession`;

    CREATE TABLE `IMRecentSession` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `userId` int(11) unsigned NOT NULL COMMENT '用户id',
      `peerId` int(11) unsigned NOT NULL COMMENT '对方id',
      `type` tinyint(1) unsigned DEFAULT '0' COMMENT '类型，1-用户,2-群组',
      `status` tinyint(1) unsigned DEFAULT '0' COMMENT '用户:0-正常, 1-用户A删除,群组:0-正常, 1-被删除',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      PRIMARY KEY (`id`),
      KEY `idx_userId_peerId_status_updated` (`userId`,`peerId`,`status`,`updated`),
      KEY `idx_userId_peerId_type` (`userId`,`peerId`,`type`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


    # Dump of table IMRelationShip
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMRelationShip`;

    CREATE TABLE `IMRelationShip` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `smallId` int(11) unsigned NOT NULL COMMENT '用户A的id',
      `bigId` int(11) unsigned NOT NULL COMMENT '用户B的id',
      `status` tinyint(1) unsigned DEFAULT '0' COMMENT '用户:0-正常, 1-用户A删除,群组:0-正常, 1-被删除',
      `created` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
      PRIMARY KEY (`id`),
      KEY `idx_smallId_bigId_status_updated` (`smallId`,`bigId`,`status`,`updated`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


    # Dump of table IMUser
    # ------------------------------------------------------------

    DROP TABLE IF EXISTS `IMUser`;

    CREATE TABLE `IMUser` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id',
      `sex` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1男2女0未知',
      `name` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '用户名',
      `domain` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '拼音',
      `nick` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '花名,绰号等',
      `password` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '密码',
      `salt` varchar(4) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '混淆码',
      `phone` varchar(11) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '手机号码',
      `email` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'email',
      `avatar` varchar(255) COLLATE utf8mb4_bin DEFAULT '' COMMENT '自定义用户头像',
      `departId` int(11) unsigned NOT NULL COMMENT '所属部门Id',
      `status` tinyint(2) unsigned DEFAULT '0' COMMENT '1. 试用期 2. 正式 3. 离职 4.实习',
      `created` int(11) unsigned NOT NULL COMMENT '创建时间',
      `updated` int(11) unsigned NOT NULL COMMENT '更新时间',
      `push_shield_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0关闭勿扰 1开启勿扰',
      `sign_info` varchar(128) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '个性签名',
      PRIMARY KEY (`id`),
      KEY `idx_domain` (`domain`),
      KEY `idx_name` (`name`),
      KEY `idx_phone` (`phone`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


