im-platform.sql 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. create table `im_user`(
  2. `id` bigint not null auto_increment primary key comment 'id',
  3. `user_name` varchar(255) not null comment '用户名',
  4. `nick_name` varchar(255) not null comment '用户昵称',
  5. `head_image` varchar(255) default '' comment '用户头像',
  6. `head_image_thumb` varchar(255) default '' comment '用户头像缩略图',
  7. `password` varchar(255) not null comment '密码',
  8. `sex` tinyint(1) default 0 comment '性别 0:男 1:女',
  9. `is_banned` tinyint(1) default 0 comment '是否被封禁 0:否 1:是',
  10. `reason` varchar(255) default '' comment '被封禁原因',
  11. `type` smallint default 1 comment '用户类型 1:普通用户 2:审核账户',
  12. `signature` varchar(1024) default '' comment '个性签名',
  13. `last_login_time` datetime DEFAULT null comment '最后登录时间',
  14. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  15. unique key `idx_user_name`(user_name),
  16. key `idx_nick_name`(nick_name)
  17. ) ENGINE=InnoDB CHARSET=utf8mb4 comment '用户';
  18. create table `im_friend`(
  19. `id` bigint not null auto_increment primary key comment 'id',
  20. `user_id` bigint not null comment '用户id',
  21. `friend_id` bigint not null comment '好友id',
  22. `friend_nick_name` varchar(255) not null comment '好友昵称',
  23. `friend_head_image` varchar(255) default '' comment '好友头像',
  24. `deleted` tinyint comment '删除标识 0:正常 1:已删除',
  25. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  26. key `idx_user_id` (`user_id`),
  27. key `idx_friend_id` (`friend_id`)
  28. ) ENGINE=InnoDB CHARSET=utf8mb4 comment '好友';
  29. create table `im_private_message`(
  30. `id` bigint not null auto_increment primary key comment 'id',
  31. `send_id` bigint not null comment '发送用户id',
  32. `recv_id` bigint not null comment '接收用户id',
  33. `content` text comment '发送内容',
  34. `type` tinyint(1) NOT NULL comment '消息类型 0:文字 1:图片 2:文件 3:语音 4:视频 21:提示',
  35. `status` tinyint(1) NOT NULL comment '状态 0:未读 1:已读 2:撤回 3:已读',
  36. `send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
  37. key `idx_send_id` (`send_id`),
  38. key `idx_recv_id` (`recv_id`)
  39. )ENGINE=InnoDB CHARSET=utf8mb4 comment '私聊消息';
  40. create table `im_group`(
  41. `id` bigint not null auto_increment primary key comment 'id',
  42. `name` varchar(255) not null comment '群名字',
  43. `owner_id` bigint not null comment '群主id',
  44. `head_image` varchar(255) default '' comment '群头像',
  45. `head_image_thumb` varchar(255) default '' comment '群头像缩略图',
  46. `notice` varchar(1024) default '' comment '群公告',
  47. `is_banned` tinyint(1) default 0 comment '是否被封禁 0:否 1:是',
  48. `reason` varchar(255) default '' comment '被封禁原因',
  49. `dissolve` tinyint(1) default 0 comment '是否已解散',
  50. `created_time` datetime default CURRENT_TIMESTAMP comment '创建时间'
  51. )ENGINE=InnoDB CHARSET=utf8mb4 comment '群';
  52. create table `im_group_member`(
  53. `id` bigint not null auto_increment primary key comment 'id',
  54. `group_id` bigint not null comment '群id',
  55. `user_id` bigint not null comment '用户id',
  56. `user_nick_name` varchar(255) DEFAULT '' comment '用户昵称',
  57. `remark_nick_name` varchar(255) DEFAULT '' comment '显示昵称备注',
  58. `head_image` varchar(255) DEFAULT '' comment '用户头像',
  59. `remark_group_name` varchar(255) DEFAULT '' comment '显示群名备注',
  60. `quit` tinyint(1) DEFAULT 0 comment '是否已退出',
  61. `quit_time` datetime DEFAULT NULL comment '退出时间',
  62. `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间',
  63. key `idx_group_id`(`group_id`),
  64. key `idx_user_id`(`user_id`)
  65. )ENGINE=InnoDB CHARSET=utf8mb4 comment '群成员';
  66. create table `im_group_message`(
  67. `id` bigint not null auto_increment primary key comment 'id',
  68. `group_id` bigint not null comment '群id',
  69. `send_id` bigint not null comment '发送用户id',
  70. `send_nick_name` varchar(255) DEFAULT '' comment '发送用户昵称',
  71. `recv_ids` varchar(1024) DEFAULT '' comment '接收用户id,逗号分隔,为空表示发给所有成员',
  72. `content` text comment '发送内容',
  73. `at_user_ids` varchar(1024) comment '被@的用户id列表,逗号分隔',
  74. `receipt` tinyint DEFAULT 0 comment '是否回执消息',
  75. `receipt_ok` tinyint DEFAULT 0 comment '回执消息是否完成',
  76. `type` tinyint(1) NOT NULL comment '消息类型 0:文字 1:图片 2:文件 3:语音 4:视频 21:提示' ,
  77. `status` tinyint(1) DEFAULT 0 comment '状态 0:未发出 2:撤回 ',
  78. `send_time` datetime DEFAULT CURRENT_TIMESTAMP comment '发送时间',
  79. key `idx_group_id` (group_id)
  80. )ENGINE=InnoDB CHARSET=utf8mb4 comment '群消息';
  81. create table `im_sensitive_word`(
  82. `id` bigint not null auto_increment primary key comment 'id',
  83. `content` varchar(64) not null comment '敏感词内容',
  84. `enabled` tinyint DEFAULT 0 COMMENT '是否启用 0:未启用 1:启用',
  85. `creator` bigint DEFAULT NULL COMMENT '创建者',
  86. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
  87. )ENGINE=InnoDB CHARSET=utf8mb4 comment '敏感词';
  88. CREATE TABLE `im_file_info` (
  89. `id` BIGINT NOT NULL auto_increment PRIMARY key comment 'id',
  90. `file_name` VARCHAR(255) NOT NULL comment '文件名',
  91. `file_path` VARCHAR(255) NOT NULL comment '文件地址',
  92. `file_size` INTEGER NOT NULL comment '文件大小',
  93. `file_type` tinyint NOT NULL comment '0:普通文件 1:图片 2:视频',
  94. `compressed_path` VARCHAR(255) DEFAULT NULL comment '压缩文件路径',
  95. `cover_path` VARCHAR(255) DEFAULT NULL comment '封面文件路径,仅视频文件有效',
  96. `upload_time` datetime DEFAULT CURRENT_TIMESTAMP comment '上传时间',
  97. `is_permanent` tinyint DEFAULT 0 comment '是否永久文件',
  98. `md5` VARCHAR(64) NOT NULL comment '文件md5',
  99. UNIQUE KEY `idx_md5` (md5)
  100. ) ENGINE = InnoDB CHARSET = utf8mb4 comment '文件';