Commit 7826e960 authored by Julien Schröter's avatar Julien Schröter Committed by Frederik Wegner
Browse files

Resolve "User university issue"

parent d10017d7
......@@ -109,6 +109,7 @@ CREATE TABLE IF NOT EXISTS `university` (
`shortform` VARCHAR(127),
`city` VARCHAR(45),
`country` VARCHAR(45),
`domain` VARCHAR(252),
PRIMARY KEY (`iduniversity`)
);
......@@ -123,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `maintainer` (
`level` INT NOT NULL, -- 3: CC, 2: SubA, 1: A, 0: SA
`name` VARCHAR(45) CHARACTER SET 'utf8mb4',
`university` INT UNSIGNED NOT NULL,
`email` VARCHAR(45) NULL,
`email` VARCHAR(254) NULL,
`idmongo` VARCHAR(45) NULL,
PRIMARY KEY (`idmaintainer`),
UNIQUE INDEX `idmaintainer_UNIQUE` (`idmaintainer` ASC),
......@@ -263,6 +264,7 @@ CREATE TABLE IF NOT EXISTS `question` (
`verified` TINYINT NOT NULL,
`published` TINYINT NOT NULL,
`answertype` ENUM('option', 'text') NOT NULL, -- enum has to be the same in answer
`university` INT UNSIGNED NULL,
PRIMARY KEY (`idquestion`),
UNIQUE INDEX `idquestion_UNIQUE` (`idquestion` ASC),
INDEX `fk_question_author_idx` (`author` ASC),
......@@ -280,6 +282,11 @@ CREATE TABLE IF NOT EXISTS `question` (
CONSTRAINT `fk_question_image`
FOREIGN KEY (`image`)
REFERENCES `resource` (`idresource`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_question_university`
FOREIGN KEY (`university`)
REFERENCES `university` (`iduniversity`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
......@@ -331,14 +338,14 @@ CREATE TABLE IF NOT EXISTS `user` (
`time_registered` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`username` VARCHAR(45) NOT NULL,
`password` VARCHAR(64) NOT NULL,
`email` VARCHAR(45) NULL,
`email` VARCHAR(254) NULL,
`semester` INT UNSIGNED NULL,
`experience` INT NOT NULL,
`level` INT UNSIGNED AS (FLOOR(POW(`experience` / 3.4,0.33333)) + 1) PERSISTENT,
`selected_avatar` INT UNSIGNED NULL,
`selected_title` INT UNSIGNED NULL DEFAULT 0,
`selected_avatar` INT UNSIGNED NOT NULL DEFAULT 1,
`selected_title` INT UNSIGNED NOT NULL DEFAULT 1,
`verified` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`university` VARCHAR(45) NULL,
`university` INT UNSIGNED NULL,
`idmongo` VARCHAR(45),
`memorycoins` INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`iduser`),
......@@ -347,6 +354,11 @@ CREATE TABLE IF NOT EXISTS `user` (
UNIQUE INDEX `email_UNIQUE` (`email` ASC),
INDEX `fk_user_avatar_idx` (`selected_avatar` ASC),
INDEX `fk_user_title_idx` (`selected_title` ASC),
CONSTRAINT `fk_user_university`
FOREIGN KEY (`university`)
REFERENCES `university` (`iduniversity`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_user_avatar`
FOREIGN KEY (`selected_avatar`)
REFERENCES `avatar` (`idavatar`)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment