diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-08-20 10:24:47 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-12-21 19:43:13 +0200 |
| commit | 218f9a92813eda3268144aa126363ff49285a6ee (patch) | |
| tree | a404efd3166f3b0cd5638f13058d3f8c9548f617 /migrations | |
| parent | 84b353a6f23a5f6a679d54ba173196689a619fe7 (diff) | |
Enable strict tables
Diffstat (limited to 'migrations')
| -rw-r--r-- | migrations/0000_initial.sql | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/migrations/0000_initial.sql b/migrations/0000_initial.sql index a9f11c8..443e0cc 100644 --- a/migrations/0000_initial.sql +++ b/migrations/0000_initial.sql @@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS polls ( lower(hex(randomblob(6)))), title TEXT NOT NULL, description TEXT, - pub_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + pub_date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, author_name TEXT NOT NULL, author_email TEXT, manage_code TEXT DEFAULT (lower(hex(randomblob(4))) || '-' || @@ -21,8 +21,8 @@ CREATE TABLE IF NOT EXISTS polls ( substr('4' || substr(lower(hex(randomblob(2))), 2, 3), 1, 4) || '-' || substr(hex((random() & 0x3fff) | 0x8000), 1, 4) || '-' || lower(hex(randomblob(6)))), - whole_day BOOLEAN NOT NULL -); + whole_day INTEGER NOT NULL +) STRICT; CREATE TABLE IF NOT EXISTS choices ( id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(4))) || '-' || @@ -31,10 +31,10 @@ CREATE TABLE IF NOT EXISTS choices ( substr(hex((random() & 0x3fff) | 0x8000), 1, 4) || '-' || lower(hex(randomblob(6)))), poll_id TEXT NOT NULL, - start_datetime TIMESTAMP NOT NULL, - end_datetime TIMESTAMP NOT NULL, + start_datetime TEXT NOT NULL, + end_datetime TEXT NOT NULL, FOREIGN KEY (poll_id) REFERENCES polls (id) ON DELETE CASCADE -); +) STRICT; CREATE TABLE IF NOT EXISTS votes ( id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(4))) || '-' || @@ -54,7 +54,7 @@ CREATE TABLE IF NOT EXISTS votes ( UNIQUE (poll_id, choice_id, voter_name), FOREIGN KEY (choice_id) REFERENCES choices (id) ON DELETE CASCADE, FOREIGN KEY (poll_id) REFERENCES polls (id) ON DELETE CASCADE -); +) STRICT; CREATE INDEX IF NOT EXISTS idx_votes_poll_id_voter_name ON votes (poll_id, voter_name); CREATE INDEX IF NOT EXISTS idx_choices_poll_id_start_datetime ON choices (poll_id, start_datetime); |
