feat: register INSERT now uses status='registered' + registration_time=NOW()
This commit is contained in:
7
release/migrate_add_registered_status.sql
Normal file
7
release/migrate_add_registered_status.sql
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
-- Migration: Add 'registered' status to videos status 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]));
|
||||||
@@ -1036,7 +1036,7 @@ async fn register_single_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let videos_table = schema::table_name("videos");
|
let videos_table = schema::table_name("videos");
|
||||||
let status = "pending";
|
let status = "registered";
|
||||||
let _ = sqlx::query(&format!(
|
let _ = sqlx::query(&format!(
|
||||||
"INSERT INTO {} (file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, status, content_hash, registration_time) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW()) ON CONFLICT (file_uuid) DO UPDATE SET file_path = EXCLUDED.file_path, file_name = EXCLUDED.file_name, status = EXCLUDED.status, content_hash = EXCLUDED.content_hash",
|
"INSERT INTO {} (file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, status, content_hash, registration_time) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW()) ON CONFLICT (file_uuid) DO UPDATE SET file_path = EXCLUDED.file_path, file_name = EXCLUDED.file_name, status = EXCLUDED.status, content_hash = EXCLUDED.content_hash",
|
||||||
videos_table
|
videos_table
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ pub struct StorageStatus {
|
|||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum VideoStatus {
|
pub enum VideoStatus {
|
||||||
|
Registered,
|
||||||
Pending,
|
Pending,
|
||||||
Processing,
|
Processing,
|
||||||
Completed,
|
Completed,
|
||||||
@@ -150,6 +151,7 @@ pub enum VideoStatus {
|
|||||||
impl VideoStatus {
|
impl VideoStatus {
|
||||||
pub fn as_str(&self) -> &'static str {
|
pub fn as_str(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
|
VideoStatus::Registered => "registered",
|
||||||
VideoStatus::Pending => "pending",
|
VideoStatus::Pending => "pending",
|
||||||
VideoStatus::Processing => "processing",
|
VideoStatus::Processing => "processing",
|
||||||
VideoStatus::Completed => "completed",
|
VideoStatus::Completed => "completed",
|
||||||
@@ -159,6 +161,7 @@ impl VideoStatus {
|
|||||||
|
|
||||||
pub fn from_db_str(s: &str) -> Option<Self> {
|
pub fn from_db_str(s: &str) -> Option<Self> {
|
||||||
match s {
|
match s {
|
||||||
|
"registered" => Some(VideoStatus::Registered),
|
||||||
"pending" => Some(VideoStatus::Pending),
|
"pending" => Some(VideoStatus::Pending),
|
||||||
"processing" => Some(VideoStatus::Processing),
|
"processing" => Some(VideoStatus::Processing),
|
||||||
"completed" => Some(VideoStatus::Completed),
|
"completed" => Some(VideoStatus::Completed),
|
||||||
|
|||||||
Reference in New Issue
Block a user