forked from rpiambulance/training
-
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
Showing
4 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,4 @@ | ||
Place any .sql files you would like to be populated to the database | ||
into this directory. They will be executed in alphabetical order. | ||
|
||
Note: you must rebuild your containers for this to take effect. |
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,374 @@ | ||
-- MySQL Script generated by MySQL Workbench | ||
-- Fri May 10 16:44:15 2019 | ||
-- Model: New Model Version: 1.0 | ||
-- MySQL Workbench Forward Engineering | ||
|
||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; | ||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; | ||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; | ||
|
||
-- ----------------------------------------------------- | ||
-- Schema training | ||
-- ----------------------------------------------------- | ||
|
||
-- ----------------------------------------------------- | ||
-- Schema training | ||
-- ----------------------------------------------------- | ||
CREATE SCHEMA IF NOT EXISTS `training` DEFAULT CHARACTER SET utf8 ; | ||
USE `training` ; | ||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`users` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`users` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`googleUserId` VARCHAR(25) NOT NULL, | ||
`radioNum` INT UNSIGNED NULL, | ||
`active` TINYINT NOT NULL, | ||
`admin` TINYINT NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`googleUserId`)); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`emsCerts` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`emsCerts` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(255) NOT NULL, | ||
`abbr` VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`name`), | ||
UNIQUE KEY (`abbr`)); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`otherCerts` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`otherCerts` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(255) NOT NULL, | ||
`org` VARCHAR(255) NULL, | ||
PRIMARY KEY (`id`)); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`usersEmsCerts` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`usersEmsCerts` ( | ||
`userId` INT UNSIGNED NOT NULL, | ||
`emsCertId` INT UNSIGNED NOT NULL, | ||
`expiration` DATETIME NOT NULL, | ||
PRIMARY KEY (`userId`, `emsCertId`), | ||
CONSTRAINT `FK_emsCert` | ||
FOREIGN KEY (`emsCertId`) | ||
REFERENCES `training`.`emsCerts` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_userEmsCert` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`usersOtherCerts` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`usersOtherCerts` ( | ||
`userId` INT UNSIGNED NOT NULL, | ||
`otherCertId` INT UNSIGNED NOT NULL, | ||
PRIMARY KEY (`userId`, `otherCertId`), | ||
CONSTRAINT `FK_userOtherCert` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_otherCert` | ||
FOREIGN KEY (`otherCertId`) | ||
REFERENCES `training`.`otherCerts` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`credentials` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`credentials` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(255) NOT NULL, | ||
`abbr` VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`name`), | ||
UNIQUE KEY (`abbr`)); | ||
|
||
INSERT INTO credentials (name, abbr) VALUES ('Duty Supervisor', 'DS'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Emergency Event Supervisor', 'EES'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Crew Chief Trainer', 'CCT'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Crew Chief', 'CC'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Probationary Crew Chief', 'PCC'); | ||
INSERT INTO credentials (name, abbr) VALUES ('First Reponse Crew Chief', 'FRCC'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Cleared Crew Chief', 'ACC'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Driver Trainer', 'DT'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Driver', 'D'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Probationary Driver', 'PD'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Cleared Driver', 'AD'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Attendant', 'A'); | ||
INSERT INTO credentials (name, abbr) VALUES ('Observer', 'O'); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`usersCredentials` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`usersCredentials` ( | ||
`userId` INT UNSIGNED NOT NULL, | ||
`credentialId` INT UNSIGNED NOT NULL, | ||
`active` TINYINT NOT NULL, | ||
`date` DATETIME NOT NULL, | ||
PRIMARY KEY (`userId`, `credentialId`), | ||
CONSTRAINT `FK_credential` | ||
FOREIGN KEY (`credentialId`) | ||
REFERENCES `training`.`credentials` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_userCredential` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`sections` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`sections` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (`id`)); | ||
|
||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`checklistItems` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`checklistItems` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`credentialId` INT UNSIGNED NOT NULL, | ||
`sectionId` INT UNSIGNED NOT NULL, | ||
`text` VARCHAR(255) NOT NULL, | ||
`active` TINYINT NOT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT `FK_checklistItemCredential` | ||
FOREIGN KEY (`credentialId`) | ||
REFERENCES `training`.`credentials` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_section` | ||
FOREIGN KEY (`sectionId`) | ||
REFERENCES `training`.`sections` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`usersChecklistItems` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`usersChecklistItems` ( | ||
`userId` INT UNSIGNED NOT NULL, | ||
`checklistItemId` INT UNSIGNED NOT NULL, | ||
`comments` TEXT NULL, | ||
`status` TINYINT NOT NULL, | ||
`trainer` INT UNSIGNED NULL, | ||
`date` DATETIME NULL, | ||
PRIMARY KEY (`userId`, `checklistItemId`), | ||
CONSTRAINT `FK_userChecklistItem` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_checklistItem` | ||
FOREIGN KEY (`checklistItemId`) | ||
REFERENCES `training`.`checklistItems` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_trainerChecklistItem` | ||
FOREIGN KEY (`trainer`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`driversLicenses` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`driversLicenses` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`userId` INT UNSIGNED NOT NULL, | ||
`number` VARCHAR(255) NOT NULL, | ||
`state` VARCHAR(255) NULL, | ||
`expiration` DATETIME NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT `FK_userDriversLicense` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`evals` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`evals` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`trainee` INT UNSIGNED NOT NULL, | ||
`trainer` INT UNSIGNED NOT NULL, | ||
`date` VARCHAR(255) NOT NULL, | ||
`credential` INT UNSIGNED NOT NULL, | ||
`comments` TEXT NULL, | ||
`passed` TINYINT NOT NULL, | ||
PRIMARY KEY (`id`, `credential`), | ||
CONSTRAINT `FK_evalTrainee` | ||
FOREIGN KEY (`trainee`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_evalTrainer` | ||
FOREIGN KEY (`trainer`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_evalCredential` | ||
FOREIGN KEY (`credential`) | ||
REFERENCES `training`.`credentials` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`evalItems` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`evalItems` ( | ||
`id` INT UNSIGNED NOT NULL, | ||
`name` VARCHAR(255) NOT NULL, | ||
`gradingType` SMALLINT NOT NULL, | ||
PRIMARY KEY (`id`)); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`usersEvalItems` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`usersEvalItems` ( | ||
`userid` INT UNSIGNED NOT NULL, | ||
`evalItemId` INT UNSIGNED NOT NULL, | ||
`score` INT NOT NULL, | ||
`comments` TEXT NULL, | ||
PRIMARY KEY (`userid`, `evalItemId`), | ||
CONSTRAINT `FK_userEvalItem` | ||
FOREIGN KEY (`userid`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_evalItem` | ||
FOREIGN KEY (`evalItemId`) | ||
REFERENCES `training`.`evalItems` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`promoRequests` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`promoRequests` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Needs to exist in the case of multiple requests by a single user', | ||
`userId` INT UNSIGNED NOT NULL, | ||
`credentialId` INT UNSIGNED NOT NULL, | ||
`approved` TINYINT NULL, | ||
`comments` TEXT NULL, | ||
PRIMARY KEY (`id`, `userId`, `credentialId`), | ||
CONSTRAINT `FK_promoRequestUser` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_promoRequestCredential` | ||
FOREIGN KEY (`credentialId`) | ||
REFERENCES `training`.`credentials` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`promoRequestVotes` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`promoRequestVotes` ( | ||
`promoRequestId` INT UNSIGNED NOT NULL, | ||
`userId` INT UNSIGNED NOT NULL, | ||
`vote` TINYINT NOT NULL, | ||
`comments` TEXT NULL, | ||
PRIMARY KEY (`promoRequestId`, `userId`), | ||
CONSTRAINT `FK_promoRequest` | ||
FOREIGN KEY (`promoRequestId`) | ||
REFERENCES `training`.`promoRequests` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_userPromoRequestVote` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`positions` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`positions` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`userId` INT UNSIGNED NOT NULL, | ||
`position` SMALLINT NOT NULL COMMENT '“1” could be TC chair, “2” could be TC member, etc', | ||
`startDate` DATETIME NOT NULL, | ||
`endDate` DATETIME NOT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT `FK_userPosition` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Table `training`.`proxyVoters` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `training`.`proxyVoters` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`userId` INT UNSIGNED NOT NULL, | ||
`tcChair` INT UNSIGNED NOT NULL, | ||
`date` DATETIME NOT NULL, | ||
`proxyFor` INT UNSIGNED NOT NULL, | ||
`complete` TINYINT NOT NULL, | ||
`promoRequestId` INT UNSIGNED NOT NULL, | ||
PRIMARY KEY (`id`), | ||
CONSTRAINT `FK_userProxyVoter` | ||
FOREIGN KEY (`userId`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_tcChairProxyVoter` | ||
FOREIGN KEY (`tcChair`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_proxyForProxyVoter` | ||
FOREIGN KEY (`proxyFor`) | ||
REFERENCES `training`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `FK_proxyPromoRequest` | ||
FOREIGN KEY (`promoRequestId`) | ||
REFERENCES `training`.`promoRequests` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION) ; | ||
|
||
|
||
SET SQL_MODE=@OLD_SQL_MODE; | ||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; | ||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.