-
Notifications
You must be signed in to change notification settings - Fork 198
/
zblog.sql
196 lines (177 loc) · 6.88 KB
/
zblog.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50534
Source Host : localhost:3306
Source Database : zblog
Target Server Type : MYSQL
Target Server Version : 50534
File Encoding : 65001
Date: 2015-01-09 21:51:26
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `category`
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`id` varchar(19) NOT NULL,
`name` varchar(25) NOT NULL,
`leftv` int(11) NOT NULL,
`rightv` int(11) NOT NULL,
`visible` tinyint(1) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of category
-- ----------------------------
INSERT INTO `category` VALUES ('Mf2DuehP8rWqS8EzyXb', 'Root', '1', '2', '0', '2014-12-18 19:37:58');
-- ----------------------------
-- Table structure for `comment`
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
`id` varchar(19) NOT NULL,
`postid` varchar(19) NOT NULL,
`parent` varchar(19) DEFAULT NULL,
`creator` varchar(25) NOT NULL,
`email` varchar(50) NOT NULL,
`url` varchar(80) NOT NULL,
`agent` varchar(120) NOT NULL,
`ip` varchar(15) NOT NULL,
`content` varchar(200) NOT NULL,
`status` enum('wait','approve','reject','trash') NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `index_comment_post` (`postid`),
KEY `index_parent` (`parent`) USING BTREE,
CONSTRAINT `index_comment` FOREIGN KEY (`parent`) REFERENCES `comment` (`id`) ON DELETE CASCADE,
CONSTRAINT `index_comment_post` FOREIGN KEY (`postid`) REFERENCES `post` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of comment
-- ----------------------------
-- ----------------------------
-- Table structure for `link`
-- ----------------------------
DROP TABLE IF EXISTS `link`;
CREATE TABLE `link` (
`id` varchar(19) NOT NULL,
`name` varchar(80) NOT NULL,
`url` varchar(100) NOT NULL,
`notes` varchar(150) DEFAULT NULL,
`visible` tinyint(1) NOT NULL DEFAULT '1',
`creator` varchar(20) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of link
-- ----------------------------
INSERT INTO `link` VALUES ('6ChkuVe0kfLY8ZiDnqZ', 'JavaTalk', 'http://www.zhouhaocheng.cn', null, '1', 'admin', '2015-01-06 17:27:31');
-- ----------------------------
-- Table structure for `options`
-- ----------------------------
DROP TABLE IF EXISTS `options`;
CREATE TABLE `options` (
`id` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`value` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of options
-- ----------------------------
INSERT INTO `options` VALUES ('title','title','Zblog');
INSERT INTO `options` VALUES ('subtitle','subtitle','Just another zblog website');
INSERT INTO `options` VALUES ('description','description','Spring Mybatis Ehcache Shiro Lucene FreeMarker');
INSERT INTO `options` VALUES ('allowComment','allowComment','true');
INSERT INTO `options` VALUES ('maxshow','maxshow','10');
-- ----------------------------
-- Table structure for `post`
-- ----------------------------
DROP TABLE IF EXISTS `post`;
CREATE TABLE `post` (
`id` varchar(19) NOT NULL,
`title` varchar(100) NOT NULL,
`excerpt` varchar(350) DEFAULT NULL,
`content` mediumtext NOT NULL,
`type` enum('post','page') NOT NULL,
`parent` varchar(19) DEFAULT NULL,
`categoryid` varchar(19) DEFAULT NULL,
`pstatus` varchar(10) NOT NULL,
`cstatus` varchar(10) NOT NULL,
`ccount` int(11) NOT NULL,
`rcount` int(11) NOT NULL,
`creator` varchar(19) NOT NULL,
`createTime` datetime NOT NULL,
`lastUpdate` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `index_post_category` (`categoryid`),
KEY `index_post_user` (`creator`),
CONSTRAINT `index_post_category` FOREIGN KEY (`categoryid`) REFERENCES `category` (`id`) ON UPDATE CASCADE,
CONSTRAINT `index_post_user` FOREIGN KEY (`creator`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of post
-- ----------------------------
-- ----------------------------
-- Table structure for `tag`
-- ----------------------------
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
`id` varchar(19) NOT NULL,
`name` varchar(15) NOT NULL,
`postid` varchar(19) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `postid` (`postid`),
CONSTRAINT `tag_post_index` FOREIGN KEY (`postid`) REFERENCES `post` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for `upload`
-- ----------------------------
DROP TABLE IF EXISTS `upload`;
CREATE TABLE `upload` (
`id` varchar(19) NOT NULL,
`postid` varchar(19) DEFAULT NULL,
`name` varchar(80) NOT NULL,
`path` varchar(100) NOT NULL,
`creator` varchar(25) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `index_upload_post` (`postid`),
CONSTRAINT `index_upload_post` FOREIGN KEY (`postid`) REFERENCES `post` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of upload
-- ----------------------------
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` varchar(19) NOT NULL,
`nickName` varchar(25) NOT NULL,
`realName` varchar(25) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(30) NOT NULL,
`status` varchar(10) NOT NULL,
`role` enum('admin','editor','contributor') NOT NULL,
`description` varchar(100) DEFAULT NULL,
`createTime` datetime NOT NULL,
`creator` varchar(15) DEFAULT NULL,
`lastUpdate` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_name` (`nickName`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('uHHi9gvg81UXn4PLlLE', 'admin', '东方上人', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 'N', 'admin', null, '2014-12-31 18:49:44', null, '2014-12-31 18:49:48');
-- ----------------------------
-- View structure for `view_category`
-- ----------------------------
DROP VIEW IF EXISTS `view_category`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_category` AS select `n`.`id` AS `id`,`n`.`name` AS `name`,count(`n`.`id`) AS `level`,`n`.`visible` AS `visible` from (`category` `n` join `category` `p`) where (`n`.`leftv` between `p`.`leftv` and `p`.`rightv`) group by `n`.`id` order by `n`.`leftv` ;