create.sql 7.86 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 34 35 36 37 38
  `title` varchar(64) NOT NULL COMMENT '标题',
  `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 58 59 60
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',
  PRIMARY KEY (`id`),
  KEY `theme_id` (`theme_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题附件';
张辰's avatar
张辰 committed
61 62

CREATE TABLE `comment` (
刘基明's avatar
刘基明 committed
63 64 65 66
  `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
67
  `author_id` varchar(64) NOT NULL COMMENT '作者id',
刘基明's avatar
刘基明 committed
68 69 70
  `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
71
  `is_block` int(4) NOT NULL DEFAULT '0' COMMENT '是否屏蔽',
刘基明's avatar
刘基明 committed
72
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
73
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
74
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
75 76 77
  PRIMARY KEY (`id`),
  KEY `idx_author` (`author_id`) USING BTREE,
  KEY `idx_target` (`reply_id`) USING BTREE
张辰's avatar
张辰 committed
78 79 80 81
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论';


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


CREATE TABLE `topic` (
刘基明's avatar
刘基明 committed
97 98
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
  `topic_id` varchar(64) NOT NULL COMMENT 'uuid',
刘基明's avatar
刘基明 committed
99
  `topic_title` varchar(64) NOT NULL COMMENT '话题名称',
张辰's avatar
张辰 committed
100 101
  `is_top` int(4) NOT NULL COMMENT '是否置顶',
  `is_conceal` int(4) NOT NULL COMMENT '是否隐藏',
刘基明's avatar
刘基明 committed
102
  `view_cnt_adjust` bigint NOT NULL DEFAULT 0 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 106 107 108 109 110
  `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
111 112 113 114 115 116
  `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
117
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
刘基明's avatar
刘基明 committed
118
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
119
  `delete_tag` int(3) NOT NULL DEFAULT '0',
刘基明's avatar
刘基明 committed
120 121 122
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_logic` (`file_oss_key`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件';
张辰's avatar
张辰 committed
123 124 125


CREATE TABLE `black_list` (
刘基明's avatar
刘基明 committed
126
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
127
  `blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
刘基明's avatar
刘基明 committed
128
  `blocked_type` int(4) NOT NULL COMMENT '屏蔽类型,1:用户,2:内容',
张辰's avatar
张辰 committed
129 130
  `blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
  `create_by` varchar(64) DEFAULT '',
刘基明's avatar
刘基明 committed
131 132
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
133 134 135 136 137 138 139
  `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
140
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
141 142 143 144
  `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
145 146
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
147 148 149 150 151 152 153
  `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
154
  `id` int(32) auto_increment PRIMARY KEY COMMENT 'id',
张辰's avatar
张辰 committed
155 156 157 158 159 160
  `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
161 162
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
张辰's avatar
张辰 committed
163 164 165 166 167 168
  `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='浏览记录';