-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bec1050
commit 898a1ea
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
CREATE TABLE IF NOT EXISTS `Users` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, | ||
`username` varchar(20) NOT NULL, | ||
`email` varchar(100) NOT NULL, | ||
`password` tinyblob NOT NULL, | ||
`super` tinyint(1) NOT NULL DEFAULT '0', | ||
`image` longblob, | ||
`first_name` varchar(20) NOT NULL, | ||
`last_name` varchar(20) NOT NULL, | ||
`verified` tinyint(1) NOT NULL DEFAULT '0', | ||
PRIMARY KEY (`id`) | ||
); | ||
CREATE TABLE IF NOT EXISTS `Tokens` ( | ||
`token` tinyblob NOT NULL, | ||
`user` int NOT NULL, | ||
`type` int NOT NULL, | ||
CONSTRAINT FK_TOKEN_USER FOREIGN KEY (user) REFERENCES Users(id) | ||
); | ||
CREATE TABLE IF NOT EXISTS `Posts` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, | ||
`author` int NOT NULL, | ||
`title` varchar(100) NOT NULL, | ||
`content` varchar(1000) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT FK_POST_AUTHOR FOREIGN KEY (author) REFERENCES Users(id) | ||
); | ||
CREATE TABLE IF NOT EXISTS `Comments` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, | ||
`author` int NOT NULL, | ||
`post` int NOT NULL, | ||
`content` varchar(1000) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT FK_COMMENT_AUTHOR FOREIGN KEY (author) REFERENCES Users(id), | ||
CONSTRAINT FK_COMMENT_POST FOREIGN KEY (post) REFERENCES Posts(id) | ||
); | ||
CREATE TABLE IF NOT EXISTS `Votes` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`user` int NOT NULL, | ||
`type` enum('true', 'false', 'null') NOT NULL, | ||
`parent_comment` int DEFAULT NULL, | ||
`parent_post` int DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT FK_VOTE_POST FOREIGN KEY (parent_post) REFERENCES Posts(id), | ||
CONSTRAINT FK_VOTE_COMMENT FOREIGN KEY (parent_comment) REFERENCES Comments(id) | ||
); |