feat: add migration for rendering_qc status in MongoDB schema
The rendering_qc status was added to the Python model but was missing from the MongoDB schema validator, causing WriteError when setting job status during QC re-rendering. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
676490ac65
commit
bcfc026e61
1 changed files with 117 additions and 0 deletions
|
|
@ -0,0 +1,117 @@
|
|||
"""Add rendering_qc status to jobs collection validator.
|
||||
|
||||
This status is used during QC re-rendering of accessible videos when the reviewer
|
||||
makes changes to pause points or queues TTS regeneration.
|
||||
"""
|
||||
|
||||
from app.migrations.migrator import Migration
|
||||
|
||||
|
||||
class Migration(Migration):
|
||||
"""Update MongoDB schema validator to support rendering_qc status."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.version = "2026-01-11-000000"
|
||||
self.description = "Add rendering_qc status to jobs collection"
|
||||
|
||||
async def up(self) -> None:
|
||||
"""Update the jobs collection validator to include rendering_qc status."""
|
||||
|
||||
# Define updated schema validator with rendering_qc 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",
|
||||
"tts_failed",
|
||||
"rendering_video",
|
||||
"render_failed",
|
||||
"rendering_qc", # NEW: Re-rendering accessible video during QC
|
||||
"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_qc status)."""
|
||||
|
||||
# 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",
|
||||
"tts_failed",
|
||||
"rendering_video",
|
||||
"render_failed",
|
||||
"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_qc status will fail validation!")
|
||||
Loading…
Add table
Reference in a new issue