create.sql 13.1 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
-- tamp_community.black_list definition

CREATE TABLE `black_list` (
   `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
   `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
   `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型,1:用户,2:内容',
   `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
   `create_by` varchar(64) DEFAULT '',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   `delete_tag` int(3) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`),
   KEY `uk_blocker` (`blocker`),
   KEY `uk_blocked` (`blocked_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='黑名单';


-- tamp_community.collection definition

CREATE TABLE `collection` (
   `id` varchar(64) NOT NULL COMMENT 'id',
   `collection_type` int(4) NOT NULL COMMENT '类型 1:点赞主题,2:收藏主题 3、点赞评论',
   `user_id` varchar(64) NOT NULL COMMENT '用户id',
   `target_id` varchar(64) NOT NULL COMMENT '目标id',
   `collection_time` datetime DEFAULT NULL COMMENT '收藏时间',
   `uncollection_time` datetime DEFAULT NULL COMMENT '取消收藏时间',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `delete_tag` int(3) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`),
   KEY `idx_author` (`user_id`) USING BTREE,
   KEY `idx_target` (`target_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收藏/点赞';


-- tamp_community.comment definition

CREATE TABLE `comment` (
  `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `comment_id` varchar(64) NOT NULL COMMENT '评论主键Id',
  `comment_type` int(4) NOT NULL COMMENT '类型 1:评论',
  `content` varchar(1024) DEFAULT NULL COMMENT '文本内容',
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
  `theme_id` varchar(64) DEFAULT NULL COMMENT '主题id',
  `parent_id` varchar(64) DEFAULT NULL COMMENT '一级评论id',
  `reply_id` varchar(64) DEFAULT NULL COMMENT '回复评论id',
  `is_pass` int(4) NOT NULL DEFAULT '0' COMMENT '是否通过 0:初始值  1:已通过(管理后台使用)',
  `report_status` int(4) NOT NULL DEFAULT '0' COMMENT '举报状态 0:未被举报  1:被举报 2:已处理',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_author` (`author_id`) USING BTREE,
  KEY `idx_target` (`reply_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论';


-- tamp_community.file_record definition

CREATE TABLE `file_record` (
    `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `file_id` varchar(64) NOT NULL COMMENT '文件主键Id',
    `file_type` int(4) NOT NULL COMMENT '类型:1:图片',
    `file_name` varchar(64) NOT NULL COMMENT '文件名称',
    `file_oss_key` varchar(64) NOT NULL COMMENT '阿里云key',
    `preview_url` varchar(512) DEFAULT NULL COMMENT '预签名预览url',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `delete_tag` int(3) NOT NULL DEFAULT '0',
    `ext_info` varchar(100) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_logic` (`file_oss_key`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件';


-- tamp_community.follow_rel definition

CREATE TABLE `follow_rel` (
   `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
   `follow_user_id` varchar(64) NOT NULL COMMENT '被关注的人id',
   `follower_id` varchar(64) NOT NULL COMMENT '粉丝id',
   `follow_time` datetime DEFAULT NULL COMMENT '关注时间',
   `unfollow_time` datetime DEFAULT NULL COMMENT '取消关注时间',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   `delete_tag` int(3) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`),
   UNIQUE KEY `uk_idol_follower` (`follow_user_id`,`follower_id`),
   KEY `idx_follower` (`follower_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='粉丝关系';


-- tamp_community.home_page definition
刘基明's avatar
刘基明 committed
94

张辰's avatar
张辰 committed
95
CREATE TABLE `home_page` (
刘基明's avatar
刘基明 committed
96
  `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
张辰's avatar
张辰 committed
97 98 99 100
  `user_id` varchar(64) NOT NULL COMMENT '用户id',
  `head_img` varchar(256) NOT NULL COMMENT '头像url',
  `nick_name` varchar(32) NOT NULL COMMENT '昵称',
  `introduction` varchar(256) NOT NULL COMMENT '个人简介',
刘基明's avatar
刘基明 committed
101 102
  `sex` int(3) DEFAULT NULL COMMENT '性别',
  `location` varchar(256) DEFAULT NULL COMMENT '地址',
刘基明's avatar
刘基明 committed
103 104
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
105
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
106
  PRIMARY KEY (`id`),
张辰's avatar
张辰 committed
107 108 109 110
  UNIQUE KEY `uk_userId` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个人主页';


刘基明's avatar
刘基明 committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
-- tamp_community.news_feed definition

CREATE TABLE `news_feed` (
  `id` varchar(64) NOT NULL COMMENT '主键id',
  `content` varchar(10000) NOT NULL COMMENT '动态内容',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` varchar(64) NOT NULL COMMENT '创建人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
  `delete_tag` int(1) NOT NULL DEFAULT '0' COMMENT '删除标识:0 否 1:删除',
  `org_id` varchar(64) NOT NULL DEFAULT 'qimeng' COMMENT '机构qimeng',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='动态';


-- tamp_community.news_feed_like definition

CREATE TABLE `news_feed_like` (
  `id` varchar(64) NOT NULL,
  `news_feed_id` varchar(64) DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `create_by` varchar(64) NOT NULL,
  `update_time` datetime DEFAULT NULL,
  `update_by` varchar(64) DEFAULT NULL,
  `delete_tag` int(1) NOT NULL COMMENT '删除标识  0:否 1:是',
  `org_id` varchar(64) NOT NULL DEFAULT 'qimeng' COMMENT '机构qimeng',
  PRIMARY KEY (`id`),
  KEY `idx_news_feed_id` (`news_feed_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


-- tamp_community.news_feed_res definition

CREATE TABLE `news_feed_res` (
  `id` varchar(64) NOT NULL,
  `news_feed_id` varchar(64) DEFAULT NULL COMMENT '动态id',
  `rel_type` int(1) NOT NULL COMMENT '关联类型',
  `rel_id` varchar(255) NOT NULL COMMENT '关联id',
  `product_type` int(1) DEFAULT NULL COMMENT '产品类型   rel_type等于产品生效',
  `remark` varchar(5000) DEFAULT NULL COMMENT '备注说明',
  `create_time` datetime NOT NULL,
  `create_by` varchar(64) NOT NULL,
  `update_time` datetime DEFAULT NULL,
  `update_by` varchar(64) DEFAULT NULL,
  `delete_tag` int(1) DEFAULT NULL COMMENT '删除标识 0:否 1:是',
  `org_id` varchar(64) NOT NULL DEFAULT 'qimeng' COMMENT '机构qimeng',
  PRIMARY KEY (`id`),
  KEY `idx_news_feed_id` (`news_feed_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


-- tamp_community.report_log definition

CREATE TABLE `report_log` (
  `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `user_id` varchar(64) NOT NULL COMMENT '举报发起人',
  `report_type` int(4) NOT NULL COMMENT '举报类型,1:主题,2:评论 3、用户',
  `target_id` varchar(64) NOT NULL COMMENT '举报对象id',
  `target_user_id` varchar(64) NOT NULL COMMENT '举报对象作者id',
  `report_reason` varchar(64) DEFAULT NULL,
  `report_time` datetime NOT NULL COMMENT '上报时间',
  `deal_result` int(4) DEFAULT NULL COMMENT '处理结果 0:无操作 1:屏蔽 2:删除 ',
  `deal_user_id` int(4) DEFAULT NULL COMMENT '处理管理员',
  `deal_time` datetime DEFAULT NULL COMMENT '处理时间',
刘基明's avatar
刘基明 committed
175
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
176
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
177
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
178 179 180 181
  PRIMARY KEY (`id`),
  KEY `uk_user` (`user_id`),
  KEY `uk_report_target_id` (`target_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='举报记录';
张辰's avatar
张辰 committed
182 183


刘基明's avatar
刘基明 committed
184 185
-- tamp_community.theme definition

张辰's avatar
张辰 committed
186
CREATE TABLE `theme` (
刘基明's avatar
刘基明 committed
187
  `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
188
  `theme_id` varchar(64) NOT NULL COMMENT '主题主键Id',
刘基明's avatar
刘基明 committed
189
  `title` varchar(64) DEFAULT NULL COMMENT '标题',
刘基明's avatar
刘基明 committed
190
  `theme_type` int(4) NOT NULL COMMENT '类型 1:讨论无标题 2:长文有标题 3:转发',
刘基明's avatar
刘基明 committed
191 192
  `content` text COMMENT '文本内容(json),type:附件类型(108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论)),productType:基金类型(0 公募,1 私募,2 白名单,3 私有)',
  `discuss_content` varchar(256) DEFAULT NULL COMMENT '讨论中的文本',
张辰's avatar
张辰 committed
193
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
194 195 196 197
  `former_theme_id` varchar(64) DEFAULT NULL COMMENT '转发的主题',
  `topic_id` varchar(64) DEFAULT NULL COMMENT '所属的话题',
  `is_pass` int(4) NOT NULL DEFAULT '0' COMMENT '是否通过 0:初始值  1:已通过(管理后台使用)',
  `report_status` int(4) NOT NULL DEFAULT '0' COMMENT '举报状态 0:未被举报  1:被举报 2:已处理',
刘基明's avatar
刘基明 committed
198 199
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
200 201 202 203 204 205
  `delete_tag` int(3) NOT NULL DEFAULT '0' COMMENT '1:删除',
  PRIMARY KEY (`id`),
  KEY `idx_thmee_id` (`theme_id`),
  KEY `idx_author` (`author_id`),
  KEY `idx_former` (`former_theme_id`),
  KEY `idx_topic` (`topic_id`)
张辰's avatar
张辰 committed
206 207
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题内容';

刘基明's avatar
刘基明 committed
208 209 210

-- tamp_community.theme_attachment definition

刘基明's avatar
刘基明 committed
211
CREATE TABLE `theme_attachment` (
刘基明's avatar
刘基明 committed
212
  `id` varchar(64) NOT NULL COMMENT 'id',
刘基明's avatar
刘基明 committed
213
  `theme_id` varchar(64) NOT NULL COMMENT '主题ID',
刘基明's avatar
刘基明 committed
214
  `attach_type` int(4) NOT NULL COMMENT '附件类型:1:产品 2:直播 3:短视频 4:课程 5图片',
刘基明's avatar
刘基明 committed
215
  `attach_id` varchar(64) NOT NULL COMMENT '附件对应的ID',
刘基明's avatar
刘基明 committed
216
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
217
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
218
  `update_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
219 220
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
221
  `ext_info` varchar(100) DEFAULT NULL,
刘基明's avatar
刘基明 committed
222 223 224
  PRIMARY KEY (`id`),
  KEY `theme_id` (`theme_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题附件';
张辰's avatar
张辰 committed
225 226


刘基明's avatar
刘基明 committed
227
-- tamp_community.topic definition
张辰's avatar
张辰 committed
228 229

CREATE TABLE `topic` (
刘基明's avatar
刘基明 committed
230 231
  `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `topic_id` varchar(64) NOT NULL COMMENT '话题主键Id',
刘基明's avatar
刘基明 committed
232
  `topic_title` varchar(64) NOT NULL COMMENT '话题名称',
张辰's avatar
张辰 committed
233 234
  `is_top` int(4) NOT NULL COMMENT '是否置顶',
  `is_conceal` int(4) NOT NULL COMMENT '是否隐藏',
刘基明's avatar
刘基明 committed
235
  `view_cnt_adjust` bigint(20) NOT NULL DEFAULT '0' COMMENT '浏览量调整基数',
刘基明's avatar
刘基明 committed
236 237
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
238
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
239
  PRIMARY KEY (`id`),
张辰's avatar
张辰 committed
240 241 242 243 244
  UNIQUE KEY `uk_title` (`topic_title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='话题';



刘基明's avatar
刘基明 committed
245 246 247 248 249 250 251 252 253 254 255
CREATE TABLE `user_visit_statistics` (
  `id` bigint(32) unsigned NOT NULL AUTO_INCREMENT,
  `visitor_id` varchar(64) DEFAULT NULL,
  `ref_id` varchar(64) DEFAULT NULL,
  `ref_type` int(8) DEFAULT NULL,
  `total_duration` bigint(20) DEFAULT NULL,
  `first_visit_time` datetime DEFAULT NULL,
  `last_visit_time` datetime DEFAULT NULL,
  `total_visit` int(16) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
张辰's avatar
张辰 committed
256 257 258


CREATE TABLE `visit_summary` (
刘基明's avatar
刘基明 committed
259 260
  `id` bigint(32) NOT NULL COMMENT 'id',
  `ident` varchar(64) DEFAULT NULL COMMENT 'session_id',
张辰's avatar
张辰 committed
261
  `visitor_id` varchar(64) NOT NULL COMMENT '浏览者id',
刘基明's avatar
刘基明 committed
262
  `author_id` varchar(64) DEFAULT NULL COMMENT '作者id',
张辰's avatar
张辰 committed
263
  `ref_id` varchar(64) NOT NULL COMMENT '关联目标ID',
刘基明's avatar
刘基明 committed
264 265
  `ref_type` int(8) NOT NULL COMMENT '关联目标类型 1:进入话题页 2:进入主题正文 3、用户查看首页-关注',
  `duration` int(16) DEFAULT NULL COMMENT '浏览时间 单位秒',
刘基明's avatar
刘基明 committed
266
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
267
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
268
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
269 270 271 272 273
  PRIMARY KEY (`id`),
  KEY `idx_session` (`ident`) USING BTREE,
  KEY `idx_ref` (`ref_id`) USING BTREE,
  KEY `idx_visitor` (`visitor_id`) USING BTREE,
  KEY `idx_author` (`author_id`) USING BTREE
张辰's avatar
张辰 committed
274
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='浏览记录';
刘基明's avatar
刘基明 committed
275 276


刘基明's avatar
刘基明 committed
277 278 279 280 281 282 283 284 285 286 287 288 289
-- tamp_community.worker_node definition

CREATE TABLE `worker_node` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
  `host_name` varchar(64) NOT NULL COMMENT 'host name',
  `port` varchar(64) NOT NULL COMMENT 'port',
  `type` varchar(32) NOT NULL COMMENT 'node type: realhost or container',
  `launch_date` date NOT NULL COMMENT 'launch date',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'created time',
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'modified time',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_host_name_port` (`host_name`,`port`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分布式唯一ID生成,DB WorkerID Assigner for UID Generator';