From 238a22e59797d87248f610858c695e6c22545cc4 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:37:26 -0700 Subject: [PATCH] Add "NOT NULL" constraints to database columns --- database/init_database.sql | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/database/init_database.sql b/database/init_database.sql index c7de265..404addf 100644 --- a/database/init_database.sql +++ b/database/init_database.sql @@ -55,8 +55,8 @@ CREATE TABLE IF NOT EXISTS scores.sports( CREATE TABLE IF NOT EXISTS scores.divisions( division_id BIGINT GENERATED ALWAYS AS IDENTITY, division_name TEXT NOT NULL, - gender VARCHAR(1) CHECK (gender IN ( 'F', 'M' ) ), - sport_id BIGINT, + gender VARCHAR(1) NOT NULL CHECK (gender IN ( 'F', 'M' ) ), + sport_id BIGINT NOT NULL, currently_active BOOLEAN DEFAULT TRUE, PRIMARY KEY(division_id), CONSTRAINT fk_sport @@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS scores.divisions( CREATE TABLE IF NOT EXISTS scores.teams( team_id BIGINT GENERATED ALWAYS AS IDENTITY, team_name TEXT NOT NULL, - sport_id BIGINT, + sport_id BIGINT NOT NULL, currently_active BOOLEAN DEFAULT TRUE, PRIMARY KEY(team_id), CONSTRAINT fk_sport @@ -83,14 +83,14 @@ CREATE TABLE IF NOT EXISTS scores.seasons( CREATE TABLE IF NOT EXISTS scores.games( game_id BIGINT GENERATED ALWAYS AS IDENTITY, - division_id BIGINT, - season_id BIGINT, - game_date DATE, - team1_id BIGINT, - team2_id BIGINT, - team1_score INTEGER, - team2_score INTEGER, - submitter_id BIGINT, + division_id BIGINT NOT NULL, + season_id BIGINT NOT NULL, + game_date DATE NOT NULL, + team1_id BIGINT NOT NULL, + team2_id BIGINT NOT NULL, + team1_score INTEGER NOT NULL, + team2_score INTEGER NOT NULL, + submitter_id BIGINT NOT NULL, updated_timestamp TIMESTAMP WITH TIME ZONE DEFAULT now(), PRIMARY KEY(game_id), CONSTRAINT fk_division