Add submitter_id column to init_database.sql script
parent
d351885375
commit
3515be836d
|
@ -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);
|
||||
|
|
|
@ -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;
|
Reference in New Issue