diff --git a/release/migrate_add_registered_status.sql b/release/migrate_add_registered_status.sql index 9dd2013..4e57d99 100644 --- a/release/migrate_add_registered_status.sql +++ b/release/migrate_add_registered_status.sql @@ -1,7 +1,10 @@ --- Migration: Add 'registered' status to videos status check constraint +-- Migration: Add 'registered' and 'unregistered' status to videos check constraint -- Date: 2026-05-15 -- Usage: psql -U accusys -d momentry -f migrate_add_registered_status.sql ALTER TABLE videos DROP CONSTRAINT IF EXISTS chk_videos_status; ALTER TABLE videos ADD CONSTRAINT chk_videos_status - CHECK (status::text = ANY (ARRAY['registered'::text, 'pending'::text, 'processing'::text, 'completed'::text, 'failed'::text])); + CHECK (status::text = ANY (ARRAY['unregistered'::text, 'registered'::text, 'pending'::text, 'processing'::text, 'completed'::text, 'failed'::text])); + +-- Set all incomplete files to 'unregistered' (old 'pending' files that never finished pipeline) +UPDATE videos SET status = 'unregistered' WHERE status NOT IN ('completed', 'registered', 'unregistered'); diff --git a/src/core/db/postgres_db.rs b/src/core/db/postgres_db.rs index 3173e52..cda0c32 100644 --- a/src/core/db/postgres_db.rs +++ b/src/core/db/postgres_db.rs @@ -141,6 +141,7 @@ pub struct StorageStatus { #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] pub enum VideoStatus { + Unregistered, Registered, Pending, Processing, @@ -151,6 +152,7 @@ pub enum VideoStatus { impl VideoStatus { pub fn as_str(&self) -> &'static str { match self { + VideoStatus::Unregistered => "unregistered", VideoStatus::Registered => "registered", VideoStatus::Pending => "pending", VideoStatus::Processing => "processing", @@ -161,6 +163,7 @@ impl VideoStatus { pub fn from_db_str(s: &str) -> Option { match s { + "unregistered" => Some(VideoStatus::Unregistered), "registered" => Some(VideoStatus::Registered), "pending" => Some(VideoStatus::Pending), "processing" => Some(VideoStatus::Processing),