2018-06-15 18:13:59 -04:00
|
|
|
CREATE TABLE `users` (
|
2018-06-20 13:07:11 -04:00
|
|
|
`user_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
2018-06-15 18:13:59 -04:00
|
|
|
`username` VARCHAR(20) NOT NULL,
|
|
|
|
`password_hash` CHAR(73) NOT NULL,
|
2018-06-21 11:00:24 -04:00
|
|
|
`signup_date` INT UNSIGNED NOT NULL,
|
2018-06-20 13:07:11 -04:00
|
|
|
PRIMARY KEY (`user_id`)
|
2018-06-15 18:13:59 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-07-13 08:17:29 -04:00
|
|
|
CREATE TABLE `chat_messages` (
|
|
|
|
`message_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
|
|
`room_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`name_id` SMALLINT UNSIGNED DEFAULT NULL,
|
|
|
|
`date` INT UNSIGNED NOT NULL,
|
|
|
|
`message` TEXT NOT NULL,
|
|
|
|
PRIMARY KEY (`message_id`)
|
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-06-20 13:07:11 -04:00
|
|
|
CREATE TABLE `quest_meta` (
|
|
|
|
`quest_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
2018-07-23 20:19:43 -04:00
|
|
|
`quest_title` VARCHAR(300) DEFAULT NULL,
|
2018-06-15 18:13:59 -04:00
|
|
|
`owner_id` SMALLINT UNSIGNED DEFAULT NULL,
|
2018-07-11 18:25:10 -04:00
|
|
|
`open_post_id` SMALLINT UNSIGNED DEFAULT NULL,
|
2018-07-13 08:17:29 -04:00
|
|
|
PRIMARY KEY (`quest_id`),
|
|
|
|
FOREIGN KEY (`owner_id`) REFERENCES `users`(`user_id`)
|
2018-06-20 13:07:11 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
|
|
|
CREATE TABLE `quest_data` (
|
2018-07-07 19:18:08 -04:00
|
|
|
`post_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
2018-06-20 13:07:11 -04:00
|
|
|
`quest_id` SMALLINT UNSIGNED NOT NULL,
|
2018-07-26 09:15:28 -04:00
|
|
|
`page_num` TINYINT UNSIGNED NOT NULL,
|
2018-07-07 13:43:58 -04:00
|
|
|
`post_type` ENUM('text', 'dice', 'poll') NOT NULL,
|
2018-06-20 13:07:11 -04:00
|
|
|
`post` MEDIUMTEXT NOT NULL,
|
2018-06-21 20:44:43 -04:00
|
|
|
`timestamp` INT UNSIGNED NOT NULL,
|
2018-07-13 08:17:29 -04:00
|
|
|
PRIMARY KEY (`post_id`),
|
|
|
|
FOREIGN KEY (`quest_id`) REFERENCES `quest_meta`(`quest_id`)
|
2018-06-15 18:13:59 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-07-11 18:25:10 -04:00
|
|
|
CREATE TABLE `dice_calls` (
|
2018-07-07 19:18:08 -04:00
|
|
|
`post_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`dice_roll` TEXT NOT NULL,
|
|
|
|
`strict` BOOLEAN DEFAULT FALSE,
|
|
|
|
`dice_challenge` SMALLINT UNSIGNED,
|
|
|
|
`rolls_taken` TINYINT UNSIGNED,
|
2018-07-13 08:17:29 -04:00
|
|
|
FOREIGN KEY (`post_id`) REFERENCES `quest_data`(`post_id`)
|
2018-07-07 19:18:08 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-07-11 18:25:10 -04:00
|
|
|
CREATE TABLE `dice_rolls` (
|
2018-07-07 19:18:08 -04:00
|
|
|
`message_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`quest_id` SMALLINT UNSIGNED NOT NULL,
|
|
|
|
`post_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`roll_dice` TEXT NOT NULL,
|
|
|
|
`roll_results` TEXT NOT NULL,
|
2018-07-11 18:25:10 -04:00
|
|
|
`roll_total` SMALLINT UNSIGNED NOT NULL,
|
2018-07-13 08:17:29 -04:00
|
|
|
FOREIGN KEY (`message_id`) REFERENCES `chat_messages`(`message_id`),
|
|
|
|
FOREIGN KEY (`post_id`) REFERENCES `dice_calls`(`post_id`)
|
2018-07-07 19:18:08 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-07-11 18:25:10 -04:00
|
|
|
CREATE TABLE `polls` (
|
|
|
|
`post_id` MEDIUMINT UNSIGNED NOT NULL,
|
2018-07-13 08:17:29 -04:00
|
|
|
`quest_id` SMALLINT UNSIGNED NOT NULL,
|
2018-07-11 18:25:10 -04:00
|
|
|
`multi_choice` BOOLEAN DEFAULT FALSE,
|
|
|
|
`allow_writein` BOOLEAN DEFAULT FALSE,
|
2018-07-13 08:17:29 -04:00
|
|
|
FOREIGN KEY (`post_id`) REFERENCES `quest_data`(`post_id`),
|
|
|
|
FOREIGN KEY (`quest_id`) REFERENCES `quest_meta`(`quest_id`)
|
2018-07-11 18:25:10 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
|
|
|
CREATE TABLE `poll_options` (
|
2018-07-13 08:17:29 -04:00
|
|
|
`option_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
2018-07-11 18:25:10 -04:00
|
|
|
`post_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`option_text` VARCHAR(200) NOT NULL,
|
2018-07-13 08:17:29 -04:00
|
|
|
PRIMARY KEY (`option_id`),
|
|
|
|
FOREIGN KEY (`post_id`) REFERENCES `polls`(`post_id`)
|
2018-07-11 18:25:10 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|
|
|
|
|
2018-07-13 08:17:29 -04:00
|
|
|
CREATE TABLE `poll_votes` (
|
|
|
|
`option_id` MEDIUMINT UNSIGNED NOT NULL,
|
|
|
|
`ip_address` VARCHAR(32) NOT NULL,
|
2018-07-18 19:09:54 -04:00
|
|
|
FOREIGN KEY (`option_id`) REFERENCES `poll_options`(`option_id`),
|
|
|
|
UNIQUE (`option_id`, `ip_address`)
|
2018-06-15 18:13:59 -04:00
|
|
|
) ENGINE=InnoDB CHARSET utf8mb4;
|