-- Training tasks table for async training job management. -- Inference service writes pending tasks; training service polls and executes. CREATE TABLE IF NOT EXISTS training_tasks ( task_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), status VARCHAR(20) NOT NULL DEFAULT 'pending', config JSONB, created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), scheduled_at TIMESTAMP WITH TIME ZONE, started_at TIMESTAMP WITH TIME ZONE, completed_at TIMESTAMP WITH TIME ZONE, error_message TEXT, model_path TEXT, metrics JSONB ); CREATE INDEX IF NOT EXISTS idx_training_tasks_status ON training_tasks(status); CREATE INDEX IF NOT EXISTS idx_training_tasks_created ON training_tasks(created_at);