CREATE TABLE IF NOT EXISTS transcode_servers (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    url VARCHAR(500) NOT NULL,
    api_key VARCHAR(64) NOT NULL,
    max_jobs TINYINT UNSIGNED NOT NULL DEFAULT 2,
    active_jobs TINYINT UNSIGNED NOT NULL DEFAULT 0,
    is_active TINYINT(1) NOT NULL DEFAULT 1,
    status ENUM('unknown','online','offline','error') NOT NULL DEFAULT 'unknown',
    last_check DATETIME DEFAULT NULL,
    last_error VARCHAR(255) DEFAULT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_active (is_active, active_jobs)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
