forked from jintaoking/leafer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
leafer.sql
72 lines (64 loc) · 2.85 KB
/
leafer.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
CREATE TABLE `user` (
`id` bigint(64) unsigned NOT NULL,
`username` varchar(20) NOT NULL,
`password` varchar(64) NOT NULL,
`is_enabled` tinyint(1) NOT NULL DEFAULT '1',
`is_male` tinyint(1) DEFAULT NULL,
`email` varchar(32) DEFAULT NULL,
`bio` varchar(140) DEFAULT NULL,
`blog` varchar(32) DEFAULT NULL,
`created_time` datetime DEFAULT NULL,
`birthday` datetime DEFAULT NULL,
`reset_code` varchar(6) DEFAULT NULL,
`reset_empire_time` varchar(6) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE TABLE `article` (
`id` bigint(64) unsigned NOT NULL,
`title` varchar(100) DEFAULT NULL,
`body` mediumtext,
`created_time` datetime DEFAULT NULL,
`modified_time` datetime DEFAULT NULL,
`username` varchar(20) DEFAULT NULL,
`is_published` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_username` (`username`),
CONSTRAINT `fk_article_user_username` FOREIGN KEY (`username`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tag` (
`id` bigint(64) unsigned NOT NULL,
`name` varchar(20) NOT NULL,
`description` varchar(32) DEFAULT NULL,
`username` varchar(20) DEFAULT NULL,
`created_time` datetime DEFAULT NULL,
`modified_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_username` (`username`),
CONSTRAINT `fk_tag_user_username` FOREIGN KEY (`username`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `article_tag` (
`article_id` bigint(64) unsigned NOT NULL,
`tag_id` bigint(64) unsigned NOT NULL,
PRIMARY KEY (`article_id`,`tag_id`),
KEY `fk_article_tag_tag_tag_id` (`tag_id`),
CONSTRAINT `fk_article_tag_article_article_id` FOREIGN KEY (`article_id`) REFERENCES `article` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_article_tag_tag_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
CREATE TABLE `role` (
`id` bigint(64) unsigned NOT NULL,
`username` varchar(20) NOT NULL,
`role` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_username` (`username`),
CONSTRAINT `fk_user_role_user_username` FOREIGN KEY (`username`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `persistent_logins` (
`username` varchar(64) NOT NULL,
`series` varchar(64) NOT NULL,
`token` varchar(64) NOT NULL,
`last_used` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`series`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO user(id, username, password) VALUES(1, 'admin', '$2a$10$MDSRJE0SGzRWWMRdfZVq2.yfYOBQ8Y/6UMgONnmrzKMJbcB/Wi7i6');
INSERT INTO role(id, username, role) values(1, 'admin', 'ROLE_ADMIN');