Skip to content
Snippets Groups Projects
Commit a0609154 authored by Federico Hurtado's avatar Federico Hurtado
Browse files

Change sql to not create tables if they do not exist anymore.

parent 50133a5c
No related branches found
No related tags found
No related merge requests found
-- Roles permissions table
CREATE TABLE rolesPermissions (
CREATE TABLE IF NOT EXISTS rolesPermissions (
roleID INT PRIMARY KEY,
permissionLevel VARCHAR(255) NOT NULL,
permissionLevelDescription VARCHAR(255) NOT NULL
);
-- Users table (Users are the login profiles for people)
CREATE TABLE users (
CREATE TABLE IF NOT EXISTS users (
userID INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
roleID INT NOT NULL,
......@@ -14,7 +14,7 @@ CREATE TABLE users (
);
-- Table to log login/logout information
CREATE TABLE userLoginLogout (
CREATE TABLE IF NOT EXISTS userLoginLogout (
eventId INT AUTO_INCREMENT PRIMARY KEY,
eventTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
userID INT NOT NULL,
......@@ -24,27 +24,27 @@ CREATE TABLE userLoginLogout (
CREATE TABLE degreeTypeLookup (
CREATE TABLE IF NOT EXISTS degreeTypeLookup (
degreeTypeId INT PRIMARY KEY AUTO_INCREMENT,
degreeType ENUM('AS', 'BS', 'MS', 'PhD')
);
CREATE TABLE involvementType (
CREATE TABLE IF NOT EXISTS involvementType (
involvementTypeId INT PRIMARY KEY AUTO_INCREMENT,
description VARCHAR(255) NOT NULL
);
CREATE TABLE stateLookup (
CREATE TABLE IF NOT EXISTS stateLookup (
stateId INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
);
CREATE TABLE countryLookup (
CREATE TABLE IF NOT EXISTS countryLookup (
countryId INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
);
CREATE TABLE address (
CREATE TABLE IF NOT EXISTS address (
addressId INT PRIMARY KEY AUTO_INCREMENT,
address1 VARCHAR(255) NOT NULL,
address2 VARCHAR(255),
......@@ -56,7 +56,7 @@ CREATE TABLE address (
FOREIGN KEY (countryId) REFERENCES countryLookup(countryId)
);
CREATE TABLE people (
CREATE TABLE IF NOT EXISTS people (
peopleId INT PRIMARY KEY AUTO_INCREMENT,
firstName VARCHAR(255) NOT NULL,
lastName VARCHAR(255) NOT NULL,
......@@ -70,7 +70,7 @@ CREATE TABLE people (
gender ENUM('male', 'female', 'other')
);
CREATE TABLE peopleDegree (
CREATE TABLE IF NOT EXISTS peopleDegree (
peopleDegreeId INT PRIMARY KEY AUTO_INCREMENT,
peopleId INT,
degreeSubject VARCHAR(255),
......@@ -81,12 +81,12 @@ CREATE TABLE peopleDegree (
FOREIGN KEY (degreeTypeId) REFERENCES degreeTypeLookup(degreeTypeId)
);
CREATE TABLE chapterLookup (
CREATE TABLE IF NOT EXISTS chapterLookup (
chapterId INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
);
CREATE TABLE peopleXAddress (
CREATE TABLE IF NOT EXISTS peopleXAddress (
peopleId INT PRIMARY KEY,
addressId INT UNIQUE,
preferredAddress VARCHAR(255) NOT NULL,
......@@ -94,7 +94,7 @@ CREATE TABLE peopleXAddress (
FOREIGN KEY (addressId) REFERENCES address(addressId)
);
CREATE TABLE peopleContact (
CREATE TABLE IF NOT EXISTS peopleContact (
peopleContactId INT PRIMARY KEY AUTO_INCREMENT,
peopleId INT,
contactNumber VARCHAR(255) NOT NULL,
......@@ -103,13 +103,13 @@ CREATE TABLE peopleContact (
FOREIGN KEY (peopleId) REFERENCES people(peopleId)
);
CREATE TABLE involvementLookup (
CREATE TABLE IF NOT EXISTS involvementLookup (
involvementId INT PRIMARY KEY AUTO_INCREMENT,
involvementType INT,
FOREIGN KEY (involvementType) REFERENCES involvementType(involvementTypeId)
);
CREATE TABLE peopleXInvolvement (
CREATE TABLE IF NOT EXISTS peopleXInvolvement (
peopleId INT,
involvementId INT,
PRIMARY KEY (peopleId, involvementId),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment