-- G2: Code Execution Worker - Database Migration -- Creates code_exec_tasks table for tracking code execution tasks CREATE TABLE IF NOT EXISTS code_exec_tasks ( id VARCHAR(36) NOT NULL PRIMARY KEY COMMENT 'Task ID (UUID short)', language VARCHAR(20) NOT NULL DEFAULT 'python' COMMENT 'Programming language', code_preview VARCHAR(500) DEFAULT '' COMMENT 'First 200 chars of code for preview', status ENUM('running','completed','error','failed','cancelled') NOT NULL DEFAULT 'running' COMMENT 'Execution status', timeout_sec INT NOT NULL DEFAULT 30 COMMENT 'Timeout in seconds', exit_code INT DEFAULT NULL COMMENT 'Process exit code', execution_time_ms FLOAT DEFAULT 0 COMMENT 'Execution time in milliseconds', stdout MEDIUMTEXT COMMENT 'Standard output (max 50KB)', stderr MEDIUMTEXT COMMENT 'Standard error (max 50KB)', error_msg VARCHAR(2048) DEFAULT NULL COMMENT 'Error message if failed', truncated TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Whether output was truncated', created_at DATETIME NOT NULL COMMENT 'Task creation time', completed_at DATETIME DEFAULT NULL COMMENT 'Task completion time', INDEX idx_language (language), INDEX idx_status (status), INDEX idx_created_at (created_at), INDEX idx_lang_status (language, status) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Code execution task records';