CREATE TABLE IF NOT EXISTS update_log (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    user_id INT UNSIGNED NULL,
    type ENUM('cms','plugin','theme') NOT NULL,
    slug VARCHAR(100) NOT NULL DEFAULT '',
    from_version VARCHAR(50) NOT NULL DEFAULT '',
    to_version VARCHAR(50) NOT NULL,
    checksum_verified TINYINT(1) NOT NULL DEFAULT 0,
    signature_verified TINYINT(1) NOT NULL DEFAULT 0,
    success TINYINT(1) NOT NULL DEFAULT 0,
    error_message TEXT NULL,
    backup_path VARCHAR(500) NULL,
    duration_ms INT UNSIGNED NOT NULL DEFAULT 0,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_type_slug (type, slug),
    INDEX idx_created (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
