Claude 3d9dda7af1
chore(db): add the widened media job operation check as NOT VALID and validate it separately
Follows the repository's migration convention: the constraint commits
without scanning media_jobs, and a second migration validates it with a
lock that lets reads and writes continue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
2026-10-05 09:59:23 +00:00

16 lines
823 B
SQL

-- analyze_video jobs read a video and report its cut points to the bot; they store no files.
-- NOT VALID commits without scanning the table; the next migration validates it.
ALTER TABLE "media_jobs" DROP CONSTRAINT "media_jobs_operation_chk";
ALTER TABLE "media_jobs" ADD CONSTRAINT "media_jobs_operation_chk" CHECK ("operation" IN (
'generate_image', 'generate_video', 'edit_image', 'edit_video', 'export_video', 'transcribe',
'analyze_video'
)) NOT VALID;
-- Studio specialists keep every media tool; ones that still edit video get the new one.
UPDATE "bots"
SET "allowedBuiltinTools" = array_append("allowedBuiltinTools", 'analyze_video')
WHERE "spawnKey" LIKE 'media:studio:%'
AND "restrictBuiltinTools"
AND 'edit_video' = ANY("allowedBuiltinTools")
AND NOT ('analyze_video' = ANY("allowedBuiltinTools"));