CREATE TABLE IF NOT EXISTS `video_review_jobs` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `uuid` CHAR(36) NOT NULL, `video_version_id` BIGINT UNSIGNED NOT NULL, `curriculum_lesson_id` BIGINT UNSIGNED NOT NULL, `prompt_version` VARCHAR(64) NOT NULL, `schema_version` VARCHAR(64) NOT NULL, `video_sha256` CHAR(64) NOT NULL, `markdown_sha256` CHAR(64) NOT NULL, `status` ENUM('queued','collecting_evidence','needs_evidence','ready_for_human_review','rejected','approved','failed','superseded') NOT NULL DEFAULT 'queued', `input_manifest_json` JSON NOT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `completed_at` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uq_review_job_uuid` (`uuid`), KEY `idx_review_job_version` (`video_version_id`,`status`), CONSTRAINT `fk_review_job_version` FOREIGN KEY (`video_version_id`) REFERENCES `video_versions` (`id`) ON DELETE RESTRICT, CONSTRAINT `fk_review_job_lesson` FOREIGN KEY (`curriculum_lesson_id`) REFERENCES `curriculum_lessons` (`id`) ON DELETE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `video_review_reports` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `video_review_job_id` BIGINT UNSIGNED NOT NULL, `recommendation` ENUM('reject','revise','manual_review','ready_for_human_review') NOT NULL, `report_json` JSON NOT NULL, `reviewer_id` BIGINT UNSIGNED NULL, `human_decision` ENUM('pending','approved','rejected') NOT NULL DEFAULT 'pending', `reviewed_at` TIMESTAMP NULL DEFAULT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uq_review_report_job` (`video_review_job_id`), CONSTRAINT `fk_review_report_job` FOREIGN KEY (`video_review_job_id`) REFERENCES `video_review_jobs` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;