-
Notifications
You must be signed in to change notification settings - Fork 2
/
db.sql
68 lines (62 loc) · 2.66 KB
/
db.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
-- 数据库
CREATE DATABASE `personal_site` DEFAULT CHARACTER SET utf8;
-- 文章表
CREATE TABLE IF NOT EXISTS `articles` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`title` varchar(1024) NOT NULL,
`description` text NOT NULL,
`content` longtext NOT NULL,
`category` int(11) DEFAULT -1,
-- `tags` varchar(256) DEFAULT NULL,
`relation_articles` varchar(256) DEFAULT NULL,
`uv` int(11) DEFAULT '0',
`deleted` tinyint(4) DEFAULT 0,
`create_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 分类表
CREATE TABLE IF NOT EXISTS `categoies` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(1024) NOT NULL,
`deleted` tinyint(4) DEFAULT 0,
`create_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 标签表
CREATE TABLE IF NOT EXISTS `tags` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar(1024) NOT NULL,
`deleted` tinyint(4) DEFAULT 0,
`create_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_by` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zhaosaisai',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 评论
CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`ip` varchar(32) NOT NULL,
`article_id` int(11) NOT NULL,
`comment` text NOT NULL,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ip白名单表
CREATE TABLE IF NOT EXISTS `white_ips` (
`ip` varchar(32) NOT NULL
);
-- 文章和标签对应表
CREATE TABLE IF NOT EXISTS `article_tag_map`(
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`article_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL
)
-- 文章和分类对应表
CREATE TABLE IF NOT EXISTS `article_category_map`(
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`article_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL
)