Add submitter_id column to init_database.sql script

main
sudoer777 2021-11-25 18:49:31 -07:00
parent d351885375
commit 3515be836d
2 changed files with 16 additions and 15 deletions

View File

@ -26,7 +26,6 @@ async function Initialize() {
}
async function checkForDatabaseInitialization() {
const query = `SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'scores'`;
let result = await executeQuery(query);

View File

@ -30,6 +30,18 @@ accounts:
BEGIN;
CREATE SCHEMA IF NOT EXISTS accounts;
CREATE TABLE IF NOT EXISTS accounts.users(
user_id BIGINT GENERATED ALWAYS AS IDENTITY,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
admin BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY(user_id)
);
CREATE SCHEMA IF NOT EXISTS scores;
@ -78,7 +90,7 @@ CREATE TABLE IF NOT EXISTS scores.games(
team2_id BIGINT,
team1_score INTEGER,
team2_score INTEGER,
/* submitter_id BIGINT,*/
submitter_id BIGINT,
updated_timestamp TIMESTAMP WITH TIME ZONE DEFAULT now(),
PRIMARY KEY(game_id),
CONSTRAINT fk_division
@ -92,20 +104,10 @@ CREATE TABLE IF NOT EXISTS scores.games(
REFERENCES scores.teams(team_id),
CONSTRAINT fk_team2
FOREIGN KEY(team2_id)
REFERENCES scores.teams(team_id)
/* CONSTRAINT fk_submitter
REFERENCES scores.teams(team_id),
CONSTRAINT fk_submitter
FOREIGN KEY(submitter_id)
REFERENCES accounts.users(user_id)*/
);
CREATE SCHEMA IF NOT EXISTS accounts;
CREATE TABLE IF NOT EXISTS accounts.users(
user_id BIGINT GENERATED ALWAYS AS IDENTITY,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
admin BOOLEAN NOT NULL DEFAULT FALSE
REFERENCES accounts.users(user_id)
);
COMMIT;