From 3ccace2a73c2ca148bc4183453fa4e5345099f44 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Wed, 19 Jun 2019 04:29:52 -0700 Subject: [PATCH] database: Update constraints to allow null edit inputs in state DONE This allows manual uploads to work without needing to fill all the edit fields with junk. We also set a constraint on uploader asserting that any videos from claimed onwards have a known uploader. Again, an exception is made for DONE to allow manual uploads. --- common/common/database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/common/database.py b/common/common/database.py index 548e8e2..5c63e4c 100644 --- a/common/common/database.py +++ b/common/common/database.py @@ -43,14 +43,14 @@ CREATE TABLE IF NOT EXISTS events ( allow_holes BOOLEAN NOT NULL DEFAULT FALSE, uploader_whitelist TEXT[], upload_location TEXT CHECK (state = 'UNEDITED' OR upload_location IS NOT NULL), - video_start TIMESTAMP CHECK (state = 'UNEDITED' OR video_start IS NOT NULL), - video_end TIMESTAMP CHECK (state = 'UNEDITED' OR video_end IS NOT NULL), - video_title TEXT CHECK (state = 'UNEDITED' OR video_title IS NOT NULL), - video_description TEXT CHECK (state = 'UNEDITED' OR video_description IS NOT NULL), - video_channel TEXT CHECK (state = 'UNEDITED' OR video_channel IS NOT NULL), + video_start TIMESTAMP CHECK (state IN ('UNEDITED', 'DONE') OR video_start IS NOT NULL), + video_end TIMESTAMP CHECK (state IN ('UNEDITED', 'DONE') OR video_end IS NOT NULL), + video_title TEXT CHECK (state IN ('UNEDITED', 'DONE') OR video_title IS NOT NULL), + video_description TEXT CHECK (state IN ('UNEDITED', 'DONE') OR video_description IS NOT NULL), + video_channel TEXT CHECK (state IN ('UNEDITED', 'DONE') OR video_channel IS NOT NULL), video_quality TEXT NOT NULL DEFAULT 'source', state event_state NOT NULL DEFAULT 'UNEDITED', - uploader TEXT, + uploader TEXT CHECK (state IN ('UNEDITED', 'EDITED', 'DONE') OR uploader IS NOT NULL), error TEXT, video_id TEXT, video_link TEXT CHECK (state != 'DONE' OR video_link IS NOT NULL)