add approved_source and qc_feedback job statuses to MongoDB schema
- Add migration to update jobs collection validator with new statuses - Update mongodb-init.js for fresh deployments - Fix deploy.sh to properly run migrations with 'python migrate.py up' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1ff3290081
commit
e6578e0ccf
3 changed files with 111 additions and 4 deletions
|
|
@ -0,0 +1,104 @@
|
|||
"""Add approved_source and qc_feedback statuses to jobs collection validator."""
|
||||
|
||||
from app.migrations.migrator import Migration
|
||||
|
||||
|
||||
class Migration(Migration):
|
||||
"""Update MongoDB schema validator to support approved_source and qc_feedback statuses."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.version = "2025-12-22-000000"
|
||||
self.description = "Add approved_source and qc_feedback statuses to jobs collection"
|
||||
|
||||
async def up(self) -> None:
|
||||
"""Update the jobs collection validator to include new status values."""
|
||||
|
||||
# Define updated schema validator with new statuses
|
||||
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", # NEW: For non-English source videos
|
||||
"rejected",
|
||||
"qc_feedback", # NEW: For QC feedback state
|
||||
"translating",
|
||||
"tts_generating",
|
||||
"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 approved_source and qc_feedback)."""
|
||||
|
||||
# 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",
|
||||
"rejected",
|
||||
"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 approved_source or qc_feedback status will fail validation!")
|
||||
|
|
@ -216,8 +216,11 @@ deploy_frontend() {
|
|||
run_migrations() {
|
||||
print_header "Running Database Migrations"
|
||||
|
||||
print_info "Running migrations..."
|
||||
docker compose $COMPOSE_FILES exec -T api python migrate.py
|
||||
print_info "Checking migration status..."
|
||||
docker compose $COMPOSE_FILES exec -T api python migrate.py status
|
||||
|
||||
print_info "Applying pending migrations..."
|
||||
docker compose $COMPOSE_FILES exec -T api python migrate.py up
|
||||
print_success "Migrations completed"
|
||||
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ db.createCollection('jobs', {
|
|||
title: { bsonType: 'string' },
|
||||
status: {
|
||||
enum: ['created', 'ingesting', 'ai_processing', 'pending_qc',
|
||||
'approved_english', 'rejected', 'translating', 'tts_generating',
|
||||
'pending_final_review', 'completed']
|
||||
'approved_english', 'approved_source', 'rejected', 'qc_feedback',
|
||||
'translating', 'tts_generating', 'pending_final_review', 'completed']
|
||||
},
|
||||
client_id: { bsonType: 'string' },
|
||||
created_at: { bsonType: 'date' },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue