-
Notifications
You must be signed in to change notification settings - Fork 234
/
init.sql
153 lines (118 loc) · 6 KB
/
init.sql
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
use mysql;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'root';
# create test_user
CREATE USER 'test_user'@'%' IDENTIFIED BY '123456';
GRANT ALL ON *.* to test_user@'%' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
-- 创建数据库
CREATE DATABASE IF NOT EXISTS `eagle`;
USE `eagle`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
# Dump of table user_fans
# ------------------------------------------------------------
DROP TABLE IF EXISTS `user_fans`;
CREATE TABLE `user_fans` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`follower_uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '粉丝的uid',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态 1:已关注 0:取消关注',
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_uid_fid` (`user_id`,`follower_uid`),
KEY `idx_status_uid` (`status`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户粉丝表';
LOCK TABLES `user_fans` WRITE;
/*!40000 ALTER TABLE `user_fans` DISABLE KEYS */;
INSERT INTO `user_fans` (`id`, `user_id`, `follower_uid`, `status`, `created_at`, `updated_at`)
VALUES
(1,2,1,1,'2020-05-23 00:12:30',NULL),
(2,3,1,1,'2020-05-23 00:23:10',NULL);
/*!40000 ALTER TABLE `user_fans` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table user_follow
# ------------------------------------------------------------
DROP TABLE IF EXISTS `user_follow`;
CREATE TABLE `user_follow` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发起关注的人',
`followed_uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '被关注用户的uid',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '关注状态 1:已关注 0:取消关注',
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_uid_fuid` (`user_id`,`followed_uid`),
KEY `idx_status_uid` (`status`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户关注表';
LOCK TABLES `user_follow` WRITE;
/*!40000 ALTER TABLE `user_follow` DISABLE KEYS */;
INSERT INTO `user_follow` (`id`, `user_id`, `followed_uid`, `status`, `created_at`, `updated_at`)
VALUES
(1,1,2,1,'2020-05-23 00:12:30',NULL),
(2,1,3,1,'2020-05-23 00:23:10',NULL);
/*!40000 ALTER TABLE `user_follow` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table user_stat
# ------------------------------------------------------------
DROP TABLE IF EXISTS `user_stat`;
CREATE TABLE `user_stat` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`follow_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '关注数',
`follower_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '粉丝数',
`status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '状态 1:正常',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_uid` (`user_id`),
KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户统计表';
LOCK TABLES `user_stat` WRITE;
/*!40000 ALTER TABLE `user_stat` DISABLE KEYS */;
INSERT INTO `user_stat` (`id`, `user_id`, `follow_count`, `follower_count`, `status`, `created_at`, `updated_at`)
VALUES
(1,1,3,0,1,'2020-05-23 00:12:30','2020-05-29 12:50:54'),
(2,2,0,0,1,'2020-05-23 00:12:30','2020-05-23 00:20:09'),
(8,3,0,1,1,'2020-05-23 00:23:10',NULL);
/*!40000 ALTER TABLE `user_stat` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table user_base
# ------------------------------------------------------------
DROP TABLE IF EXISTS `user_base`;
CREATE TABLE `user_base` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL DEFAULT '',
`password` varchar(60) NOT NULL DEFAULT '',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
`phone` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '手机号',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT '邮箱',
`sex` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '性别 0:未知 1:男 2:女',
`deleted_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_username` (`username`),
UNIQUE KEY `uniq_phone` (`phone`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表';
LOCK TABLES `user_base` WRITE;
/*!40000 ALTER TABLE `user_base` DISABLE KEYS */;
INSERT INTO `user_base` (`id`, `username`, `password`, `avatar`, `phone`, `email`, `sex`, `deleted_at`, `created_at`, `updated_at`)
VALUES
(1,'test-name','$2a$10$WhJY.MCtsp5kmnyl/UAdQuWbbMzxvmLCPeDhcpxyL84lYey829/ym','/uploads/avatar.jpg',13010102020,'123@cc.com',1,NULL,'2020-02-09 10:23:33','2020-05-09 10:23:33'),
(2,'admin','$2a$10$WhJY.MCtsp5kmnyl/UAdQuWbbMzxvmLCPeDhcpxyL84lYey829/ym','13010102021',1,'1234@cc.com',0,NULL,'2020-05-20 22:42:18','2020-05-20 22:42:18'),
(3,'admin2','$2a$10$Dps9oN3Oe3ZDMACih3DCGeTvR.jW/I8WD1NqapCJ6Vq3PzjnusI9i','13010102022',0,'12345@cc.com',0,NULL,'2020-05-20 22:43:21','2020-05-20 22:43:21');
/*!40000 ALTER TABLE `user_base` ENABLE KEYS */;
UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;