Add a few NOT NULL
This commit is contained in:
@ -4,7 +4,7 @@ CREATE TABLE elections (
|
|||||||
tokens INTEGER NOT NULL,
|
tokens INTEGER NOT NULL,
|
||||||
is_anonymous INTEGER NOT NULL,
|
is_anonymous INTEGER NOT NULL,
|
||||||
max_voters INTEGER, -- mandatory when election is anonymous
|
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,
|
expires_at DATETIME NOT NULL,
|
||||||
CHECK (is_anonymous = 0 OR (is_anonymous = 1 AND max_voters IS NOT NULL AND max_voters >= 1))
|
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 (
|
CREATE TABLE votes (
|
||||||
voter_identity TEXT NOT NULL,
|
voter_identity TEXT NOT NULL,
|
||||||
election_id INTEGER NOT NULL,
|
election_id INTEGER NOT NULL,
|
||||||
choice_text TEXT,
|
choice_text TEXT NOT NULL,
|
||||||
tokens INTEGER,
|
tokens INTEGER NOT NULL,
|
||||||
calculated_vote_count GENERATED ALWAYS AS (floor(sqrt(tokens))) VIRTUAL,
|
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),
|
PRIMARY KEY (voter_identity, choice_text),
|
||||||
FOREIGN KEY (voter_identity, election_id) REFERENCES voters (identity, election_id),
|
FOREIGN KEY (voter_identity, election_id) REFERENCES voters (identity, election_id),
|
||||||
FOREIGN KEY (choice_text, election_id) REFERENCES choices (text, election_id),
|
FOREIGN KEY (choice_text, election_id) REFERENCES choices (text, election_id),
|
||||||
|
Reference in New Issue
Block a user