From 49bd090df9814788ce85d98873c5076068df5dc4 Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 27 Dec 2024 12:45:09 +0100 Subject: [PATCH] Add a few NOT NULL --- sql/init.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/init.sql b/sql/init.sql index 4311f08..b7fe1d2 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -4,7 +4,7 @@ CREATE TABLE elections ( tokens INTEGER NOT NULL, is_anonymous INTEGER NOT NULL, max_voters INTEGER, -- mandatory when election is anonymous - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, expires_at DATETIME NOT NULL, CHECK (is_anonymous = 0 OR (is_anonymous = 1 AND max_voters IS NOT NULL AND max_voters >= 1)) ); @@ -55,10 +55,10 @@ END; CREATE TABLE votes ( voter_identity TEXT NOT NULL, election_id INTEGER NOT NULL, - choice_text TEXT, - tokens INTEGER, + choice_text TEXT NOT NULL, + tokens INTEGER NOT NULL, calculated_vote_count GENERATED ALWAYS AS (floor(sqrt(tokens))) VIRTUAL, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (voter_identity, choice_text), FOREIGN KEY (voter_identity, election_id) REFERENCES voters (identity, election_id), FOREIGN KEY (choice_text, election_id) REFERENCES choices (text, election_id),