Commit 2054ce68 authored by Simon Metzler's avatar Simon Metzler
Browse files

Drop tables before creation

parent 9e2641c1
......@@ -115,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `university` (
-- -----------------------------------------------------
-- Table `maintainer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `maintainer`;
CREATE TABLE IF NOT EXISTS `maintainer` (
`idmaintainer` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`login` VARCHAR(45) NOT NULL,
......@@ -169,6 +170,7 @@ CREATE TABLE IF NOT EXISTS `subject` (
-- -----------------------------------------------------
-- Table `course`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE IF NOT EXISTS `course` (
`idcourse` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
......@@ -190,6 +192,7 @@ CREATE TABLE IF NOT EXISTS `course` (
-- -----------------------------------------------------
-- Table `subject_course`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `subject_course`;
CREATE TABLE IF NOT EXISTS `subject_course` (
`subject` INT UNSIGNED NOT NULL,
`course` INT UNSIGNED NOT NULL,
......@@ -216,6 +219,7 @@ CREATE TABLE IF NOT EXISTS `subject_course` (
-- further specifies what operations the maintainer can
-- perform.
-- -----------------------------------------------------
DROP TABLE IF EXISTS `maintainer_subject`;
CREATE TABLE IF NOT EXISTS `maintainer_subject` (
`maintainer` INT UNSIGNED NOT NULL,
`subject` INT UNSIGNED NOT NULL,
......@@ -235,6 +239,7 @@ CREATE TABLE IF NOT EXISTS `maintainer_subject` (
-- -----------------------------------------------------
-- Table `resource`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `resource`;
CREATE TABLE IF NOT EXISTS `resource` (
`idresource` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`uri` VARCHAR(128) NOT NULL,
......@@ -246,6 +251,7 @@ CREATE TABLE IF NOT EXISTS `resource` (
-- -----------------------------------------------------
-- Table `question`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE IF NOT EXISTS `question` (
`idquestion` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`author` INT UNSIGNED NULL,
......@@ -282,6 +288,7 @@ CREATE TABLE IF NOT EXISTS `question` (
-- -----------------------------------------------------
-- Table `avatar`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `avatar`;
CREATE TABLE IF NOT EXISTS `avatar` (
`idavatar` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`image` INT UNSIGNED NOT NULL,
......@@ -300,6 +307,7 @@ CREATE TABLE IF NOT EXISTS `avatar` (
-- -----------------------------------------------------
-- Table `title`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `title`;
CREATE TABLE IF NOT EXISTS `title` (
`idtitle` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
......@@ -317,6 +325,7 @@ CREATE TABLE IF NOT EXISTS `title` (
-- -----------------------------------------------------
-- Table `user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`iduser` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`time_registered` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
......@@ -353,6 +362,7 @@ CREATE TABLE IF NOT EXISTS `user` (
-- -----------------------------------------------------
-- Table `pool`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pool`;
CREATE TABLE IF NOT EXISTS `pool` (
`idpool` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
......@@ -375,6 +385,7 @@ CREATE TABLE IF NOT EXISTS `pool` (
-- Table `user_pool`
-- The pools a user selected to play.
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user_pool`;
CREATE TABLE IF NOT EXISTS `user_pool` (
`user` INT UNSIGNED NOT NULL,
`pool` INT UNSIGNED NOT NULL,
......@@ -393,7 +404,8 @@ CREATE TABLE IF NOT EXISTS `user_pool` (
-- -----------------------------------------------------
-- Table `friend`
-- -----------------------------------------------------
-- -----------------------------------------------------
DROP TABLE IF EXISTS `friend`;
CREATE TABLE IF NOT EXISTS `friend` (
`user` INT UNSIGNED NOT NULL,
`friend` INT UNSIGNED NOT NULL,
......@@ -413,6 +425,7 @@ CREATE TABLE IF NOT EXISTS `friend` (
-- -----------------------------------------------------
-- Table `pool_question`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pool_question`;
CREATE TABLE IF NOT EXISTS `pool_question` (
`pool` INT UNSIGNED NOT NULL,
`question` INT UNSIGNED NOT NULL,
......@@ -435,6 +448,7 @@ CREATE TABLE IF NOT EXISTS `pool_question` (
-- -----------------------------------------------------
-- Table `explanation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `explanation`;
CREATE TABLE IF NOT EXISTS `explanation` (
`question` INT UNSIGNED NOT NULL,
`text` TEXT NULL,
......@@ -457,6 +471,7 @@ CREATE TABLE IF NOT EXISTS `explanation` (
-- -----------------------------------------------------
-- Table `textinputanswer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `textinputanswer`;
CREATE TABLE IF NOT EXISTS `textinputanswer` (
`idtextinputanswer` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`question` INT UNSIGNED NOT NULL,
......@@ -475,6 +490,7 @@ CREATE TABLE IF NOT EXISTS `textinputanswer` (
-- -----------------------------------------------------
-- Table `optionanswer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `optionanswer`;
CREATE TABLE IF NOT EXISTS `optionanswer` (
`idoptionanswer` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`image` INT UNSIGNED NULL,
......@@ -500,6 +516,7 @@ CREATE TABLE IF NOT EXISTS `optionanswer` (
-- -----------------------------------------------------
-- Table `report`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `report`;
CREATE TABLE IF NOT EXISTS `report` (
`idreport` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`question` INT UNSIGNED NOT NULL,
......@@ -517,6 +534,7 @@ CREATE TABLE IF NOT EXISTS `report` (
-- -----------------------------------------------------
-- Table `flashcard`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flashcard`;
CREATE TABLE IF NOT EXISTS `flashcard` (
`idflashcard` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`author` INT UNSIGNED NULL,
......@@ -555,6 +573,7 @@ CREATE TABLE IF NOT EXISTS `flashcard` (
-- -----------------------------------------------------
-- Table `cardsubscription`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `cardsubscription`;
CREATE TABLE IF NOT EXISTS `cardsubscription` (
`flashcard` INT UNSIGNED NOT NULL,
`user` INT UNSIGNED NOT NULL,
......@@ -577,6 +596,7 @@ CREATE TABLE IF NOT EXISTS `cardsubscription` (
-- -----------------------------------------------------
-- Table `traininglist`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `traininglist`;
CREATE TABLE IF NOT EXISTS `traininglist` (
`author` INT UNSIGNED NOT NULL,
`subject` INT UNSIGNED NOT NULL,
......@@ -600,6 +620,7 @@ CREATE TABLE IF NOT EXISTS `traininglist` (
-- -----------------------------------------------------
-- Table `trainingsubscription`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `trainingsubscription`;
CREATE TABLE IF NOT EXISTS `trainingsubscription` (
`author` INT UNSIGNED NOT NULL,
`subject` INT UNSIGNED NOT NULL,
......@@ -624,7 +645,8 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `user_title`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `user_title` (
DROP TABLE IF EXISTS `user_title`;
CREATE TABLE IF NOT EXISTS `user_title` (
`user` INT UNSIGNED NOT NULL,
`title` INT UNSIGNED NOT NULL,
PRIMARY KEY (`user`, `title`),
......@@ -645,6 +667,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `duel`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `duel`;
CREATE TABLE IF NOT EXISTS `duel` (
`idduel` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`started` INT UNSIGNED NOT NULL, -- player that started the duel
......@@ -672,6 +695,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- Table `duel_player`
-- A
-- -----------------------------------------------------
DROP TABLE IF EXISTS `duel_player`;
CREATE TABLE IF NOT EXISTS `duel_player` (
`user` INT UNSIGNED NOT NULL,
`duel` INT UNSIGNED NOT NULL,
......@@ -691,6 +715,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `round`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `round`;
CREATE TABLE IF NOT EXISTS `round` (
`idround` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`duel` INT UNSIGNED NOT NULL, -- the duel this round is part of
......@@ -715,6 +740,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `roundquestion`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `roundquestion`;
CREATE TABLE IF NOT EXISTS `roundquestion` (
`idroundquestion` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`round` INT UNSIGNED NOT NULL, -- the round this question was is played in
......@@ -735,6 +761,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `useranswer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `useranswer`;
CREATE TABLE IF NOT EXISTS `useranswer` (
`iduseranswer` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
`roundquestion` INT UNSIGNED NOT NULL, -- the roundquestion this answer was given to
......@@ -757,6 +784,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `optionuseranswer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `optionuseranswer`;
CREATE TABLE IF NOT EXISTS `optionuseranswer` (
`useranswer` INT UNSIGNED NOT NULL,
`selected` INT UNSIGNED NOT NULL, -- the akamu.option the user selected
......@@ -776,6 +804,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `textuseranswer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `textuseranswer`;
CREATE TABLE IF NOT EXISTS `textuseranswer` (
`useranswer` INT UNSIGNED NOT NULL,
`input` VARCHAR(100) NOT NULL, -- the akamu.textanswer that was given with a useranswer
......@@ -790,6 +819,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `session`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `session`;
CREATE TABLE IF NOT EXISTS `session` (
`idsession` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user` INT UNSIGNED NOT NULL,
......@@ -806,6 +836,7 @@ CREATE TABLE IF NOT EXISTS `trainingsubscription` (
-- -----------------------------------------------------
-- Table `setting`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `setting`;
CREATE TABLE IF NOT EXISTS `setting` (
`key` VARCHAR(255) NOT NULL PRIMARY KEY,
`type` ENUM('int', 'string', 'float'),
......
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