create.sql 7.98 KB
Newer Older
张辰's avatar
张辰 committed
1
CREATE TABLE `home_page` (
刘基明's avatar
刘基明 committed
2
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
3 4 5 6
  `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
7 8
  `sex` int(3) COMMENT '性别',
  `location` varchar(256) COMMENT '地址',
刘基明's avatar
刘基明 committed
9 10
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
11 12 13 14 15
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  UNIQUE KEY `uk_userId` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个人主页';


刘基明's avatar
刘基明 committed
16 17 18
CREATE TABLE `follow_rel` (
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `follow_id` varchar(64) NOT NULL COMMENT '被关注的人id',
张辰's avatar
张辰 committed
19
  `follower_id` varchar(64) NOT NULL COMMENT '粉丝id',
刘基明's avatar
刘基明 committed
20 21
  `follow_time` datetime COMMENT '关注时间',
  `unfollow_time` datetime COMMENT '取消关注时间',
刘基明's avatar
刘基明 committed
22 23
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP  ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
24
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
25
  UNIQUE KEY `uk_idol_follower` (`follow_id`, `follower_id`),
张辰's avatar
张辰 committed
26 27 28 29 30
  INDEX `idx_follower` (`follower_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='粉丝关系';


CREATE TABLE `theme` (
刘基明's avatar
刘基明 committed
31 32
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `theme_id` varchar(64) NOT NULL COMMENT 'UUID',
刘基明's avatar
刘基明 committed
33
  `title` varchar(64) COMMENT '标题',
张辰's avatar
张辰 committed
34 35 36 37 38
  `theme_type` int(4) NOT NULL COMMENT '类型',
  `content` text COMMENT '文本内容',
  `attach_type` int(4) NOT NULL COMMENT '附件类型',
  `attachment` text NOT NULL COMMENT '附件内容',
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
39
  `former_theme_id` varchar(64) COMMENT '被转发的主题',
张辰's avatar
张辰 committed
40
  `topic_id` varchar(64) NOT NULL COMMENT '所属的话题',
刘基明's avatar
刘基明 committed
41 42
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
43
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
44
  INDEX `idx_thmee_id` (`theme_id`),
张辰's avatar
张辰 committed
45 46 47 48 49
  INDEX `idx_author` (`author_id`),
  INDEX `idx_former` (`former_theme_id`),
  INDEX `idx_topic` (`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题内容';

刘基明's avatar
刘基明 committed
50 51 52 53 54 55 56 57
CREATE TABLE `theme_attachment` (
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `theme_id` varchar(64) NOT NULL COMMENT '主题ID',
  `attach_type` int(4) NOT NULL COMMENT '附件类型:1:产品 2:直播 3:短视频 4:课程 5:图片',
  `attach_id` varchar(64) NOT NULL COMMENT '附件对应的ID',
  `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
58
  `ext_info` varchar(100) DEFAULT NULL COMMENT '额外信息',
刘基明's avatar
刘基明 committed
59 60 61
  PRIMARY KEY (`id`),
  KEY `theme_id` (`theme_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题附件';
张辰's avatar
张辰 committed
62 63

CREATE TABLE `comment` (
刘基明's avatar
刘基明 committed
64 65 66 67
  `id` int(32) auto_increment PRIMARY KEY NOT NULL COMMENT 'id',
  `comment_id` varchar(64) NOT NULL COMMENT 'uuid',
  `comment_type` int(4) NOT NULL COMMENT '类型',
  `content` varchar(1024) DEFAULT NULL COMMENT '文本内容',
张辰's avatar
张辰 committed
68
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
69 70 71
  `theme_id` varchar(64) DEFAULT NULL COMMENT '主题id',
  `parent_id` varchar(64) DEFAULT NULL COMMENT '一级评论id',
  `reply_id` varchar(64) DEFAULT NULL COMMENT '回复评论id',
刘基明's avatar
刘基明 committed
72
  `is_block` int(4) NOT NULL DEFAULT '0' COMMENT '是否屏蔽',
刘基明's avatar
刘基明 committed
73
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
74
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
75
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
76 77 78
  PRIMARY KEY (`id`),
  KEY `idx_author` (`author_id`) USING BTREE,
  KEY `idx_target` (`reply_id`) USING BTREE
张辰's avatar
张辰 committed
79 80 81 82
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论';


CREATE TABLE `collection` (
刘基明's avatar
刘基明 committed
83
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
刘基明's avatar
刘基明 committed
84
  `collection_type` int(4) NOT NULL COMMENT '类型,类型 1:点赞主题,2:收藏主题 3:点赞评论',
刘基明's avatar
刘基明 committed
85
  `user_id` varchar(64) NOT NULL COMMENT '作者id',
张辰's avatar
张辰 committed
86
  `target_id` varchar(64) NOT NULL COMMENT '评论的目标id',
刘基明's avatar
刘基明 committed
87 88
  `collection_time` datetime COMMENT '收藏时间',
  `uncollection_time` datetime COMMENT '取消收藏时间',
刘基明's avatar
刘基明 committed
89 90
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
91
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
92
  INDEX `idx_author` (`user_id`),
张辰's avatar
张辰 committed
93 94 95 96 97
  INDEX `idx_target` (`target_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收藏/点赞';


CREATE TABLE `topic` (
刘基明's avatar
刘基明 committed
98 99
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `topic_id` varchar(64) NOT NULL COMMENT 'uuid',
刘基明's avatar
刘基明 committed
100
  `topic_title` varchar(64) NOT NULL COMMENT '话题名称',
张辰's avatar
张辰 committed
101 102
  `is_top` int(4) NOT NULL COMMENT '是否置顶',
  `is_conceal` int(4) NOT NULL COMMENT '是否隐藏',
刘基明's avatar
刘基明 committed
103
  `view_cnt_adjust` bigint NOT NULL DEFAULT 0 COMMENT '浏览量调整',
刘基明's avatar
刘基明 committed
104 105
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
106 107 108 109 110 111
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  UNIQUE KEY `uk_title` (`topic_title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='话题';


CREATE TABLE `file_record` (
刘基明's avatar
刘基明 committed
112 113 114 115 116 117
  `id` int(32) auto_increment NOT NULL COMMENT 'id',
  `file_id` varchar(64) NOT NULL COMMENT 'UUID',
  `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',
刘基明's avatar
刘基明 committed
118
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
119
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
120
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
121
  `ext_info` varchar(100) DEFAULT NULL COMMENT '额外信息',
刘基明's avatar
刘基明 committed
122 123 124
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_logic` (`file_oss_key`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件';
张辰's avatar
张辰 committed
125 126 127


CREATE TABLE `black_list` (
刘基明's avatar
刘基明 committed
128
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
129
  `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
刘基明's avatar
刘基明 committed
130
  `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型,1:用户,2:内容',
张辰's avatar
张辰 committed
131 132
  `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
133 134
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
135 136 137 138 139 140 141
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `uk_blocker` (`blocker`),
  INDEX `uk_blocked` (`blocked_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='黑名单';


CREATE TABLE `black_list` (
刘基明's avatar
刘基明 committed
142
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
143 144 145 146
  `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
  `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型',
  `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
147 148
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
149 150 151 152 153 154 155
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `uk_blocker` (`blocker`),
  INDEX `uk_blocked` (`blocked_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='黑名单';


CREATE TABLE `visit_summary` (
刘基明's avatar
刘基明 committed
156
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
157 158 159 160 161 162
  `session_id` varchar(64) NOT NULL COMMENT 'session_id',
  `visitor_id` varchar(64) NOT NULL COMMENT '浏览者id',
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
  `ref_id` varchar(64) NOT NULL COMMENT '关联目标ID',
  `ref_type` int(8) NOT NULL COMMENT '关联目标类型',
  `duration` int(16) NOT NULL COMMENT '浏览时间 单位秒',
刘基明's avatar
刘基明 committed
163 164
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
165 166 167 168 169 170
  `delete_tag` int(3) NOT NULL DEFAULT '0',
  INDEX `idx_session` (`session_id`),
  INDEX `idx_ref` (`ref_id`),
  INDEX `idx_visitor` (`visitor_id`),
  INDEX `idx_author` (`author_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='浏览记录';