create.sql 15.4 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3
-- tamp_community.collection definition

CREATE TABLE `collection` (
刘基明's avatar
刘基明 committed
4
                              `id` varchar(64) NOT NULL COMMENT 'id',
刘基明's avatar
刘基明 committed
5 6 7
                              `collection_type` int(4) NOT NULL DEFAULT '-1' COMMENT '类型 1:点赞主题,2:收藏主题 3、点赞评论',
                              `user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '用户id',
                              `target_id` varchar(64) NOT NULL DEFAULT '' COMMENT '目标id',
刘基明's avatar
刘基明 committed
8 9 10 11 12
                              `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',
刘基明's avatar
刘基明 committed
13 14
                              PRIMARY KEY (`id`) USING BTREE,
                              UNIQUE KEY `uk_user_type_target` (`user_id`,`collection_type`,`target_id`) USING BTREE,
刘基明's avatar
刘基明 committed
15
                              KEY `idx_target_id_and_type` (`target_id`,`collection_time`) USING BTREE,
刘基明's avatar
刘基明 committed
16
                              KEY `idx_user_create_time` (`user_id`,`create_time`) USING BTREE
刘基明's avatar
刘基明 committed
17
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收藏/点赞';
刘基明's avatar
刘基明 committed
18 19 20 21 22


-- tamp_community.comment definition

CREATE TABLE `comment` (
刘基明's avatar
刘基明 committed
23
                           `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
24 25
                           `comment_id` varchar(64) NOT NULL DEFAULT '' COMMENT '评论主键Id',
                           `comment_type` int(4) NOT NULL DEFAULT '-1' COMMENT '类型 1:评论',
刘基明's avatar
刘基明 committed
26
                           `content` varchar(1024) NOT NULL DEFAULT '' COMMENT '文本内容',
刘基明's avatar
刘基明 committed
27 28
                           `author_id` varchar(64) NOT NULL DEFAULT '' COMMENT '作者id',
                           `theme_id` varchar(64) NOT NULL DEFAULT '' COMMENT '主题id',
刘基明's avatar
刘基明 committed
29 30 31 32 33 34 35
                           `parent_id` varchar(64) NOT NULL DEFAULT '' COMMENT '一级评论id',
                           `reply_id` varchar(64) NOT NULL DEFAULT '' COMMENT '回复评论id',
                           `review_status` 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',
刘基明's avatar
刘基明 committed
36
                           PRIMARY KEY (`id`) USING BTREE,
刘基明's avatar
刘基明 committed
37 38
                           UNIQUE KEY `uk_comment` (`comment_id`) USING BTREE,
                           KEY `idx_author` (`author_id`) USING BTREE,
刘基明's avatar
刘基明 committed
39 40 41
                           KEY `idx_reply` (`reply_id`) USING BTREE,
                           KEY `idx_theme` (`theme_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论';
刘基明's avatar
刘基明 committed
42 43 44 45 46


-- tamp_community.file_record definition

CREATE TABLE `file_record` (
刘基明's avatar
刘基明 committed
47
                               `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
48 49 50 51
                               `file_id` varchar(64) NOT NULL DEFAULT '' COMMENT '文件主键Id',
                               `file_type` int(4) NOT NULL DEFAULT '-1' COMMENT '类型:1:图片',
                               `file_name` varchar(64) NOT NULL DEFAULT '' COMMENT '文件名称',
                               `file_oss_key` varchar(64) NOT NULL DEFAULT '' COMMENT '阿里云key',
刘基明's avatar
刘基明 committed
52 53 54 55 56
                               `preview_url` varchar(512) NOT NULL DEFAULT '' 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,
刘基明's avatar
刘基明 committed
57 58 59
                               PRIMARY KEY (`id`) USING BTREE,
                               UNIQUE KEY `uk_fileId` (`file_id`) USING BTREE,
                               UNIQUE KEY `uk_osskey` (`file_oss_key`) USING BTREE
刘基明's avatar
刘基明 committed
60
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件';
刘基明's avatar
刘基明 committed
61 62 63 64 65


-- tamp_community.follow_rel definition

CREATE TABLE `follow_rel` (
刘基明's avatar
刘基明 committed
66
                              `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
67 68
                              `idol_id` varchar(64) NOT NULL DEFAULT '' COMMENT '被关注的人id',
                              `fans_id` varchar(64) NOT NULL DEFAULT '' COMMENT '粉丝id',
刘基明's avatar
刘基明 committed
69 70 71 72 73
                              `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',
刘基明's avatar
刘基明 committed
74 75 76 77
                              PRIMARY KEY (`id`) USING BTREE,
                              UNIQUE KEY `uk_idol_follower` (`idol_id`,`fans_id`) USING BTREE,
                              KEY `idx_follower` (`fans_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='粉丝关系';
刘基明's avatar
刘基明 committed
78 79 80 81 82 83 84 85 86 87

-- tamp_community.rank_log definition

CREATE TABLE `rank_log` (
                            `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
                            `type` int(4) NOT NULL COMMENT '1:话题 2:主题',
                            `total_count` int(11) NOT NULL COMMENT '总排序数量',
                            `page_number` int(11) NOT NULL COMMENT '页码',
                            `page_size` int(11) NOT NULL COMMENT '页面大小',
                            `content` text COMMENT '排序内容',
刘基明's avatar
刘基明 committed
88
                            `round` bigint(20) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
89 90 91 92 93
                            `rank_cost` bigint(20) NOT NULL DEFAULT '0' COMMENT '花费间隔,单位毫秒',
                            `rank_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',
刘基明's avatar
刘基明 committed
94 95
                            PRIMARY KEY (`id`) USING BTREE,
                            KEY `uk_round_pageNumber` (`type`,`round`,`page_number`) USING BTREE
刘基明's avatar
刘基明 committed
96
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='话题排序日志记录’';
刘基明's avatar
刘基明 committed
97 98 99 100 101


-- tamp_community.report_log definition

CREATE TABLE `report_log` (
刘基明's avatar
刘基明 committed
102 103 104 105 106 107 108 109 110 111 112 113 114
                              `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) NOT NULL DEFAULT '' COMMENT '举报理由',
                              `report_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '上报时间',
                              `review_result` int(4) DEFAULT NULL COMMENT '处理结果 0:无操作 1:屏蔽 2:删除 ',
                              `review_user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '处理管理员',
                              `review_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',
刘基明's avatar
刘基明 committed
115 116 117 118
                              PRIMARY KEY (`id`) USING BTREE,
                              KEY `idx_user` (`user_id`) USING BTREE,
                              KEY `idx_report_target_id` (`target_id`) USING BTREE,
                              KEY `idx_targetUserId` (`target_user_id`) USING BTREE
刘基明's avatar
刘基明 committed
119
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='举报记录';
张辰's avatar
张辰 committed
120 121


刘基明's avatar
刘基明 committed
122 123
-- tamp_community.theme definition

张辰's avatar
张辰 committed
124
CREATE TABLE `theme` (
刘基明's avatar
刘基明 committed
125
                         `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
126
                         `theme_id` varchar(64) NOT NULL DEFAULT '' COMMENT '主题主键Id',
刘基明's avatar
刘基明 committed
127
                         `title` varchar(128) NOT NULL DEFAULT '' COMMENT '标题',
刘基明's avatar
刘基明 committed
128
                         `theme_type` int(4) NOT NULL DEFAULT '-1' COMMENT '类型 1:讨论无标题 2:长文有标题 3:转发',
刘基明's avatar
刘基明 committed
129
                         `content` longtext NOT NULL COMMENT '文本内容(json),type:附件类型(108:文本,88:产品 3:直播 6:短视频 303:新版课程-音频,304: 新版课程-视频,109:单图(长文) 110:多图(讨论)),productType:基金类型(0 公募,1 私募,2 白名单,3 私有)',
刘基明's avatar
刘基明 committed
130 131 132
                         `author_id` varchar(64) NOT NULL DEFAULT '' COMMENT '作者id',
                         `former_theme_id` varchar(64) NOT NULL DEFAULT '' COMMENT '转发的主题',
                         `topic_id` varchar(64) NOT NULL DEFAULT '' COMMENT '所属的话题',
刘基明's avatar
刘基明 committed
133 134 135 136 137
                         `review_status` 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 ON UPDATE CURRENT_TIMESTAMP,
                         `delete_tag` int(3) NOT NULL DEFAULT '0' COMMENT '1:删除',
刘基明's avatar
刘基明 committed
138 139 140 141
                         PRIMARY KEY (`id`) USING BTREE,
                         UNIQUE KEY `uk_themeId` (`theme_id`) USING BTREE,
                         KEY `idx_author_createTime` (`author_id`,`create_time`) USING BTREE,
                         KEY `idx_former` (`former_theme_id`) USING BTREE,
刘基明's avatar
刘基明 committed
142
                         KEY `idx_create_time` (`create_time`) USING BTREE,
刘基明's avatar
刘基明 committed
143
                         KEY `idx_topic_id_create_time` (`topic_id`,`create_time`) USING BTREE
刘基明's avatar
刘基明 committed
144
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题内容';
张辰's avatar
张辰 committed
145

刘基明's avatar
刘基明 committed
146 147 148

-- tamp_community.theme_attachment definition

刘基明's avatar
刘基明 committed
149
CREATE TABLE `theme_attachment` (
刘基明's avatar
刘基明 committed
150
                                    `id` varchar(64) NOT NULL COMMENT 'id',
刘基明's avatar
刘基明 committed
151 152 153
                                    `theme_id` varchar(64) NOT NULL DEFAULT '' COMMENT '主题ID',
                                    `attach_type` int(4) NOT NULL DEFAULT '-1' COMMENT '附件类型:108:文本,88:产品 3:直播 6:短视频 303:新版课程-视频,304: 新版课程-音频,109:单图(长文) 110:多图(讨论))',
                                    `attach_id` varchar(64) NOT NULL DEFAULT '' COMMENT '附件对应的ID',
刘基明's avatar
刘基明 committed
154 155 156
                                    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                    `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
157 158
                                    `ext_info` varchar(512) NOT NULL DEFAULT '',
                                    PRIMARY KEY (`id`) USING BTREE,
刘基明's avatar
刘基明 committed
159
                                    KEY `theme_id` (`theme_id`) USING BTREE,
刘基明's avatar
刘基明 committed
160
                                    KEY `uk_attach_type` (`attach_id`,`attach_type`) USING BTREE
刘基明's avatar
刘基明 committed
161
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题附件';
张辰's avatar
张辰 committed
162 163


刘基明's avatar
刘基明 committed
164
-- tamp_community.topic definition
张辰's avatar
张辰 committed
165 166

CREATE TABLE `topic` (
刘基明's avatar
刘基明 committed
167
                         `id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
刘基明's avatar
刘基明 committed
168 169
                         `topic_id` varchar(64) NOT NULL DEFAULT '' COMMENT '话题主键Id',
                         `topic_title` varchar(64) NOT NULL DEFAULT '' COMMENT '话题名称',
刘基明's avatar
刘基明 committed
170 171 172 173 174 175
                         `is_top` int(4) NOT NULL DEFAULT '0' COMMENT '是否置顶',
                         `is_conceal` int(4) NOT NULL DEFAULT '0' COMMENT '是否隐藏',
                         `view_cnt_adjust` int(11) NOT NULL DEFAULT '0' 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',
刘基明's avatar
刘基明 committed
176 177 178
                         PRIMARY KEY (`id`) USING BTREE,
                         UNIQUE KEY `uk_title` (`topic_title`) USING BTREE,
                         UNIQUE KEY `uk_topicId` (`topic_id`) USING BTREE
刘基明's avatar
刘基明 committed
179
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='话题';
张辰's avatar
张辰 committed
180 181


刘基明's avatar
刘基明 committed
182 183 184
-- tamp_community.visit_log definition

CREATE TABLE `visit_log` (
刘基明's avatar
刘基明 committed
185 186 187 188 189 190 191 192 193 194
                             `id` bigint(32) NOT NULL COMMENT 'id',
                             `ident` varchar(64) NOT NULL DEFAULT '' COMMENT 'session_id',
                             `visitor_id` varchar(64) NOT NULL DEFAULT '' COMMENT '浏览者id',
                             `author_id` varchar(64) NOT NULL DEFAULT '' COMMENT '作者id',
                             `ref_id` varchar(64) NOT NULL DEFAULT '' COMMENT '关联目标ID',
                             `ref_type` varchar(16) NOT NULL DEFAULT '' COMMENT '关联目标类型 :p13508:进入话题页 p13503:进入主题正文 3、用户查看首页-关注',
                             `duration` int(16) NOT NULL DEFAULT '0' 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',
刘基明's avatar
刘基明 committed
195
                             PRIMARY KEY (`id`) USING BTREE,
刘基明's avatar
刘基明 committed
196
                             KEY `idx_session` (`ident`) USING BTREE,
刘基明's avatar
刘基明 committed
197 198
                             KEY `idx_visitor_ref` (`visitor_id`,`ref_id`,`ref_type`) USING BTREE,
                             KEY `idx_author_ref` (`author_id`,`ref_id`,`ref_type`) USING BTREE,
刘基明's avatar
刘基明 committed
199 200
                             KEY `idx_ref_id_and_type` (`ref_id`,`ref_type`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='浏览记录';
刘基明's avatar
刘基明 committed
201 202 203 204 205


-- tamp_community.worker_node definition

CREATE TABLE `worker_node` (
刘基明's avatar
刘基明 committed
206 207 208 209 210 211 212
                               `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',
刘基明's avatar
刘基明 committed
213 214
                               PRIMARY KEY (`id`) USING BTREE,
                               UNIQUE KEY `idx_host_name_port` (`host_name`,`port`) USING BTREE
刘基明's avatar
刘基明 committed
215
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分布式唯一ID生成,DB WorkerID Assigner for UID Generator';