Add submitter_id column to init_database.sql script
This commit is contained in:
		
							parent
							
								
									d351885375
								
							
						
					
					
						commit
						3515be836d
					
				
					 2 changed files with 16 additions and 15 deletions
				
			
		|  | @ -26,7 +26,6 @@ async function Initialize() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| async function checkForDatabaseInitialization() { | async function checkForDatabaseInitialization() { | ||||||
|     const query = `SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'scores'`; |     const query = `SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'scores'`; | ||||||
|     let result = await executeQuery(query); |     let result = await executeQuery(query); | ||||||
|  |  | ||||||
|  | @ -30,6 +30,18 @@ accounts: | ||||||
| BEGIN; | 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; | CREATE SCHEMA IF NOT EXISTS scores; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -78,7 +90,7 @@ CREATE TABLE IF NOT EXISTS scores.games( | ||||||
|         team2_id BIGINT, |         team2_id BIGINT, | ||||||
|         team1_score INTEGER, |         team1_score INTEGER, | ||||||
|         team2_score INTEGER, |         team2_score INTEGER, | ||||||
| /*        submitter_id BIGINT,*/ |         submitter_id BIGINT, | ||||||
|         updated_timestamp TIMESTAMP WITH TIME ZONE DEFAULT now(), |         updated_timestamp TIMESTAMP WITH TIME ZONE DEFAULT now(), | ||||||
|         PRIMARY KEY(game_id), |         PRIMARY KEY(game_id), | ||||||
|         CONSTRAINT fk_division |         CONSTRAINT fk_division | ||||||
|  | @ -92,20 +104,10 @@ CREATE TABLE IF NOT EXISTS scores.games( | ||||||
|                 REFERENCES scores.teams(team_id), |                 REFERENCES scores.teams(team_id), | ||||||
|         CONSTRAINT fk_team2 |         CONSTRAINT fk_team2 | ||||||
|             FOREIGN KEY(team2_id) |             FOREIGN KEY(team2_id) | ||||||
|                 REFERENCES scores.teams(team_id) |                 REFERENCES scores.teams(team_id), | ||||||
| /*        CONSTRAINT fk_submitter |         CONSTRAINT fk_submitter | ||||||
|             FOREIGN KEY(submitter_id) |             FOREIGN KEY(submitter_id) | ||||||
|                 REFERENCES accounts.users(user_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 |  | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| COMMIT; | COMMIT; | ||||||
		Reference in a new issue