-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_table.sql
101 lines (92 loc) · 3.9 KB
/
create_table.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
drop table picref;
drop table plugin_conf;
drop table topic;
drop table msg;
drop table author;
drop table pic_task_queue;
CREATE DATABASE usr;
CREATE TABLE `_user` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`username` varchar(16) NOT NULL,
`email` varchar(50) NOT NULL,
`nickname` varchar(40) CHARACTER SET utf8 NOT NULL,
`pwd` varbinary(64) NOT NULL,
`salt` varbinary(10) NOT NULL,
`master` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE database msghub;
CREATE TABLE `pic_task_queue` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`url` varchar(2083) NOT NULL,
`status` tinyint(3) unsigned NOT NULL,
`owner` varchar(40) NOT NULL,
`time` timestamp NULL DEFAULT NULL,
`trytimes` tinyint(4) unsigned NOT NULL DEFAULT '0',
`nodetype` varchar(20) DEFAULT NULL,
`nodenum` varchar(20) DEFAULT NULL,
`ext` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `urlIndex` (`url`),
KEY `queue` (`owner`,`status`,`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `author` (
`id` varchar(64) CHARACTER SET utf8 NOT NULL,
`coverImg` int(10) unsigned zerofill DEFAULT NULL,
`name` varchar(30) CHARACTER SET utf8mb4 NOT NULL,
PRIMARY KEY (`id`),
KEY `coverImg2pid_author` (`coverImg`),
CONSTRAINT `coverImg2pid_author` FOREIGN KEY (`coverImg`) REFERENCES `pic_task_queue` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `msg` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`SnapTime` int(10) unsigned NOT NULL,
`PubTime` int(10) unsigned NOT NULL,
`SourceURL` varchar(2083) NOT NULL,
`Body` mediumtext CHARACTER SET utf8mb4 NOT NULL,
`Title` text CHARACTER SET utf8mb4 NOT NULL,
`SubTitle` text CHARACTER SET utf8mb4 NOT NULL,
`CoverImg` int(10) unsigned zerofill DEFAULT NULL,
`ViewType` tinyint(4) NOT NULL,
`AuthorId` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`Tag` varchar(30) CHARACTER SET utf8mb4 NOT NULL,
`Topic` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `SourceURL` (`SourceURL`,`Topic`),
KEY `ma` (`AuthorId`),
KEY `SnapTime` (`SnapTime`,`id`) USING BTREE,
KEY `CoverImg` (`CoverImg`),
KEY `Topic` (`Topic`,`SnapTime`,`id`) USING BTREE,
CONSTRAINT `authorid2aid` FOREIGN KEY (`AuthorId`) REFERENCES `author` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `coverimg2pid_msg` FOREIGN KEY (`CoverImg`) REFERENCES `pic_task_queue` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `plugin_conf` (
`id` varchar(64) NOT NULL,
`plugin_type` varchar(20) NOT NULL,
`config` text CHARACTER SET utf8mb4 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `topic` (
`topic_hash` varchar(64) NOT NULL,
`title` text CHARACTER SET utf8mb4 NOT NULL,
`uid` int(10) unsigned zerofill NOT NULL,
UNIQUE KEY `uid_topic_hash` (`topic_hash`,`uid`),
KEY `uid` (`uid`),
KEY `topic_hash` (`topic_hash`),
CONSTRAINT `topic_plugin_conf_id` FOREIGN KEY (`topic_hash`) REFERENCES `plugin_conf` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `topic_uid` FOREIGN KEY (`uid`) REFERENCES `usr`.`_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `picref` (
`Ref` varchar(50) DEFAULT NULL,
`Description` text CHARACTER SET utf8mb4 NOT NULL,
`Pixes` varchar(10) DEFAULT NULL,
`pid` int(10) unsigned zerofill NOT NULL,
`mid` int(10) unsigned zerofill NOT NULL,
UNIQUE KEY `mp` (`mid`,`pid`),
KEY `forPid` (`pid`),
KEY `forMid` (`mid`),
CONSTRAINT `forMid` FOREIGN KEY (`mid`) REFERENCES `msg` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `forPid` FOREIGN KEY (`pid`) REFERENCES `pic_task_queue` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;