From 3ca70a7c0344e580b8eae7643d41d0abd67a79ea Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 27 Dec 2025 08:40:23 -0600 Subject: [PATCH] fix: add rendering_video status to MongoDB schema validator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rendering_video status was defined in job.py and frontend types but was missing from the MongoDB schema validator, causing document update failures when jobs transitioned to the rendering_video state. Changes: - Add migration script to update existing databases - Update mongodb-init.js for new database setups 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- ...12-27-000000_add_rendering_video_status.py | 107 ++++++++++++++++++ scripts/mongodb-init.js | 3 +- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 backend/app/migrations/scripts/migration_2025-12-27-000000_add_rendering_video_status.py diff --git a/backend/app/migrations/scripts/migration_2025-12-27-000000_add_rendering_video_status.py b/backend/app/migrations/scripts/migration_2025-12-27-000000_add_rendering_video_status.py new file mode 100644 index 0000000..b5a2072 --- /dev/null +++ b/backend/app/migrations/scripts/migration_2025-12-27-000000_add_rendering_video_status.py @@ -0,0 +1,107 @@ +"""Add rendering_video status to jobs collection validator.""" + +from app.migrations.migrator import Migration + + +class Migration(Migration): + """Update MongoDB schema validator to support rendering_video status.""" + + def __init__(self): + super().__init__() + self.version = "2025-12-27-000000" + self.description = "Add rendering_video status to jobs collection" + + async def up(self) -> None: + """Update the jobs collection validator to include rendering_video status.""" + + # Define updated schema validator with rendering_video status + validator = { + "$jsonSchema": { + "bsonType": "object", + "required": ["_id", "title", "status", "client_id", "created_at", "updated_at"], + "properties": { + "_id": {"bsonType": "string"}, + "title": {"bsonType": "string"}, + "status": { + "enum": [ + "created", + "ingesting", + "ai_processing", + "pending_qc", + "approved_english", + "approved_source", + "rejected", + "qc_feedback", + "translating", + "tts_generating", + "rendering_video", # NEW: Accessible video rendering in progress + "pending_final_review", + "completed" + ] + }, + "client_id": {"bsonType": "string"}, + "created_at": {"bsonType": "date"}, + "updated_at": {"bsonType": "date"} + } + } + } + + # Update the collection validator + try: + await self.db.command({ + "collMod": "jobs", + "validator": validator, + "validationLevel": "moderate", + "validationAction": "error" + }) + print(f" Updated jobs collection validator") + except Exception as e: + print(f" Could not update validator: {e}") + raise + + print(f" Applied migration {self.version}: {self.description}") + + async def down(self) -> None: + """Revert to previous validator (without rendering_video).""" + + # Define old schema validator + validator = { + "$jsonSchema": { + "bsonType": "object", + "required": ["_id", "title", "status", "client_id", "created_at", "updated_at"], + "properties": { + "_id": {"bsonType": "string"}, + "title": {"bsonType": "string"}, + "status": { + "enum": [ + "created", + "ingesting", + "ai_processing", + "pending_qc", + "approved_english", + "approved_source", + "rejected", + "qc_feedback", + "translating", + "tts_generating", + "pending_final_review", + "completed" + ] + }, + "client_id": {"bsonType": "string"}, + "created_at": {"bsonType": "date"}, + "updated_at": {"bsonType": "date"} + } + } + } + + # Update the collection validator + await self.db.command({ + "collMod": "jobs", + "validator": validator, + "validationLevel": "moderate", + "validationAction": "error" + }) + + print(f" Rolled back migration {self.version}: {self.description}") + print(f" WARNING: Jobs with rendering_video status will fail validation!") diff --git a/scripts/mongodb-init.js b/scripts/mongodb-init.js index f28addc..873157a 100644 --- a/scripts/mongodb-init.js +++ b/scripts/mongodb-init.js @@ -29,7 +29,8 @@ db.createCollection('jobs', { status: { enum: ['created', 'ingesting', 'ai_processing', 'pending_qc', 'approved_english', 'approved_source', 'rejected', 'qc_feedback', - 'translating', 'tts_generating', 'pending_final_review', 'completed'] + 'translating', 'tts_generating', 'rendering_video', + 'pending_final_review', 'completed'] }, client_id: { bsonType: 'string' }, created_at: { bsonType: 'date' },