After story 1

This commit is contained in:
2026-08-03 11:30:49 -04:00
commit 82590c392f
32 changed files with 4375 additions and 0 deletions
+122
View File
@@ -0,0 +1,122 @@
--
-- VideoDetect Database Schema
-- Version: 1.0.0
-- Created: 2026-08-03
--
-- Create database (if not exists)
CREATE DATABASE IF NOT EXISTS videodetect
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
USE videodetect;
-- -----------------------------------------------------
-- Table: videos
-- Stores metadata for each video file in the corpus
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS videos (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
file_path VARCHAR(2048) NOT NULL,
file_hash CHAR(64) NOT NULL COMMENT 'SHA-256 hash of file',
resolution_w INT DEFAULT NULL,
resolution_h INT DEFAULT NULL,
codec VARCHAR(50) DEFAULT NULL,
duration FLOAT DEFAULT NULL COMMENT 'Duration in seconds',
status ENUM('NEW', 'PENDING', 'PROCESSING', 'COMPLETED', 'UNSCANNABLE', 'ERROR')
NOT NULL DEFAULT 'NEW' COMMENT 'Processing status',
last_scan_time DATETIME DEFAULT NULL,
last_processed_time DATETIME DEFAULT NULL,
confidence_score FLOAT DEFAULT NULL COMMENT 'Video-level confidence score',
routing_decision ENUM('MATCH', 'REVIEW', 'SKIP') DEFAULT NULL COMMENT 'Routing decision',
model_version VARCHAR(50) DEFAULT NULL COMMENT 'Model version used for processing',
frame_count INT DEFAULT NULL COMMENT 'Number of frames sampled',
error_message TEXT DEFAULT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uk_file_hash (file_hash),
INDEX idx_videos_status (status),
INDEX idx_videos_last_scan (last_scan_time),
INDEX idx_videos_status_last_scan (status, last_scan_time),
INDEX idx_videos_file_path (file_path(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -----------------------------------------------------
-- Table: processing_logs
-- Audit trail for each video processing job
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS processing_logs (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
video_id BIGINT NOT NULL,
model_version VARCHAR(50) NOT NULL,
frame_count INT NOT NULL DEFAULT 0,
confidence_score FLOAT DEFAULT NULL,
confidence_scores JSON DEFAULT NULL COMMENT 'Frame-level confidence scores',
routing_decision ENUM('MATCH', 'REVIEW', 'SKIP') NOT NULL,
processed_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
error_message TEXT DEFAULT NULL,
FOREIGN KEY (video_id) REFERENCES videos(id) ON DELETE CASCADE,
INDEX idx_processing_logs_video (video_id),
INDEX idx_processing_logs_processed_at (processed_at),
INDEX idx_processing_logs_routing (routing_decision)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -----------------------------------------------------
-- Table: models
-- Model registry tracking all deployed and archived models
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS models (
version VARCHAR(50) PRIMARY KEY,
status ENUM('ACTIVE', 'CANDIDATE', 'ARCHIVED') NOT NULL DEFAULT 'CANDIDATE',
path VARCHAR(2048) NOT NULL,
calibration_temp FLOAT DEFAULT NULL COMMENT 'Temperature scaling parameter',
f1_score FLOAT DEFAULT NULL COMMENT 'F1 score on validation set',
ece_score FLOAT DEFAULT NULL COMMENT 'Expected Calibration Error',
deployed_at DATETIME DEFAULT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX idx_models_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -----------------------------------------------------
-- Table: review_queue
-- Videos awaiting manual annotation
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS review_queue (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
video_id BIGINT NOT NULL,
confidence_score FLOAT NOT NULL,
routing_decision ENUM('REVIEW') NOT NULL DEFAULT 'REVIEW',
annotated BOOLEAN NOT NULL DEFAULT FALSE,
ground_truth BOOLEAN DEFAULT NULL COMMENT 'True label from annotator',
annotated_at DATETIME DEFAULT NULL,
notes TEXT DEFAULT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (video_id) REFERENCES videos(id) ON DELETE CASCADE,
INDEX idx_review_queue_annotated (annotated),
INDEX idx_review_queue_created (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -----------------------------------------------------
-- Table: scan_history
-- Tracks directory scan operations for incremental sync
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS scan_history (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
scan_start DATETIME NOT NULL,
scan_end DATETIME DEFAULT NULL,
files_discovered INT DEFAULT 0,
files_new INT DEFAULT 0,
files_modified INT DEFAULT 0,
files_removed INT DEFAULT 0,
files_unscannable INT DEFAULT 0,
duration_seconds FLOAT DEFAULT NULL,
status ENUM('RUNNING', 'COMPLETED', 'FAILED') NOT NULL DEFAULT 'RUNNING',
error_message TEXT DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -----------------------------------------------------
-- Insert default model entry
-- -----------------------------------------------------
INSERT IGNORE INTO models (version, status, path, calibration_temp, created_at)
VALUES ('v0.0.0-placeholder', 'ACTIVE', '/models/placeholder', 1.0, NOW());