db.sql 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. use `box-im`;
  2. create table `im_user`(
  3. `id` bigint not null auto_increment primary key comment 'id',
  4. `user_name` varchar(255) not null comment '用户名',
  5. `nick_name` varchar(255) not null comment '用户昵称',
  6. `head_image` varchar(255) default '' comment '用户头像',
  7. `head_image_thumb` varchar(255) default '' comment '用户头像缩略图',
  8. `password` varchar(255) not null comment '密码(明文)',
  9. `sex` tinyint(1) default 0 comment '性别 0:男 1:女',
  10. `type` smallint default 1 comment '用户类型 1:普通用户 2:审核账户',
  11. `signature` varchar(1024) default '' comment '个性签名',
  12. `last_login_time` datetime DEFAULT null comment '最后登录时间',
  13. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  14. unique key `idx_user_name`(user_name),
  15. key `idx_nick_name`(nick_name)
  16. ) ENGINE=InnoDB CHARSET=utf8mb3 comment '用户';
  17. create table `im_friend`(
  18. `id` bigint not null auto_increment primary key comment 'id',
  19. `user_id` bigint not null comment '用户id',
  20. `friend_id` bigint not null comment '好友id',
  21. `friend_nick_name` varchar(255) not null comment '好友昵称',
  22. `friend_head_image` varchar(255) default '' comment '好友头像',
  23. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  24. key `idx_user_id` (`user_id`),
  25. key `idx_friend_id` (`friend_id`)
  26. ) ENGINE=InnoDB CHARSET=utf8mb3 comment '好友';
  27. create table `im_private_message`(
  28. `id` bigint not null auto_increment primary key comment 'id',
  29. `send_id` bigint not null comment '发送用户id',
  30. `recv_id` bigint not null comment '接收用户id',
  31. `content` text comment '发送内容',
  32. `type` tinyint(1) NOT NULL comment '消息类型 0:文字 1:图片 2:文件 3:语音 10:系统提示',
  33. `status` tinyint(1) NOT NULL comment '状态 0:未读 1:已读 2:撤回',
  34. `send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
  35. key `idx_send_recv_id` (`send_id`,`recv_id`)
  36. )ENGINE=InnoDB CHARSET=utf8mb3 comment '私聊消息';
  37. create table `im_group`(
  38. `id` bigint not null auto_increment primary key comment 'id',
  39. `name` varchar(255) not null comment '群名字',
  40. `owner_id` bigint not null comment '群主id',
  41. `head_image` varchar(255) default '' comment '群头像',
  42. `head_image_thumb` varchar(255) default '' comment '群头像缩略图',
  43. `notice` varchar(1024) default '' comment '群公告',
  44. `remark` varchar(255) default '' comment '群备注',
  45. `deleted` tinyint(1) default 0 comment '是否已删除',
  46. `created_time` datetime default CURRENT_TIMESTAMP comment '创建时间'
  47. )ENGINE=InnoDB CHARSET=utf8mb3 comment '群';
  48. create table `im_group_member`(
  49. `id` bigint not null auto_increment primary key comment 'id',
  50. `group_id` bigint not null comment '群id',
  51. `user_id` bigint not null comment '用户id',
  52. `alias_name` varchar(255) DEFAULT '' comment '组内显示名称',
  53. `head_image` varchar(255) DEFAULT '' comment '用户头像',
  54. `remark` varchar(255) DEFAULT '' comment '备注',
  55. `quit` tinyint(1) DEFAULT 0 comment '是否已退出',
  56. `quit_time` datetime DEFAULT NULL comment '退出时间',
  57. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  58. key `idx_group_id`(`group_id`),
  59. key `idx_user_id`(`user_id`)
  60. )ENGINE=InnoDB CHARSET=utf8mb3 comment '群成员';
  61. create table `im_group_message`(
  62. `id` bigint not null auto_increment primary key comment 'id',
  63. `group_id` bigint not null comment '群id',
  64. `send_id` bigint not null comment '发送用户id',
  65. `send_nick_name` varchar(255) DEFAULT '' comment '发送用户昵称',
  66. `recv_ids` varchar(1024) DEFAULT '' comment '接收用户id,逗号分隔,为空表示发给所有成员',
  67. `content` text comment '发送内容',
  68. `at_user_ids` varchar(1024) comment '被@的用户id列表,逗号分隔',
  69. `receipt` tinyint DEFAULT 0 comment '是否回执消息',
  70. `receipt_ok` tinyint DEFAULT 0 comment '回执消息是否完成',
  71. `type` tinyint(1) NOT NULL comment '消息类型 0:文字 1:图片 2:文件 3:语音 4:视频 10:系统提示' ,
  72. `status` tinyint(1) DEFAULT 0 comment '状态 0:未发出 1:已送达 2:撤回 3:已读',
  73. `send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
  74. key `idx_group_id` (group_id)
  75. )ENGINE=InnoDB CHARSET=utf8mb3 comment '群消息';