# Installer Upgrades Configuration Fragment

[[elements]]
border_bottom = false
border_top = true
name = "upgrades_section_header"
title = "📦 Upgrades Configuration"
type = "section_header"

# Auto-Upgrade Settings
[[elements]]
default = false
help = "Enable automatic system updates and upgrades"
name = "auto_upgrade_enabled"
nickel_path = ["installer", "upgrades", "auto_upgrade", "enabled"]
prompt = "Enable Auto-Upgrade"
type = "confirm"

[[elements]]
condition = "auto_upgrade_enabled == true"
default = true
help = "Check for updates at startup"
name = "check_updates_on_startup"
nickel_path = ["installer", "upgrades", "auto_upgrade", "check_on_startup"]
prompt = "Check Updates on Startup"
type = "confirm"

[[elements]]
condition = "auto_upgrade_enabled == true"
default = false
help = "Automatically apply patches without confirmation"
name = "auto_apply_patches"
nickel_path = ["installer", "upgrades", "auto_upgrade", "auto_apply_patches"]
prompt = "Auto-Apply Patches"
type = "confirm"

# Update Channels
[[elements]]
default = "stable"
help = "Software update channel preference"
name = "update_channel"
nickel_path = ["installer", "upgrades", "update_channel"]
options = ["stable", "lts", "beta", "nightly"]
prompt = "Update Channel"
type = "select"

# Upgrade Strategy
[[elements]]
default = "rolling"
help = "Strategy for applying upgrades"
name = "upgrade_strategy"
nickel_path = ["installer", "upgrades", "strategy"]
options = ["rolling", "blue_green", "canary", "maintenance_window"]
prompt = "Upgrade Strategy"
type = "select"

[[elements]]
condition = "upgrade_strategy == 'rolling'"
default = 1
help = "Number of services to upgrade in parallel"
max = 10
min = 1
name = "rolling_upgrade_parallel"
nickel_path = ["installer", "upgrades", "rolling", "parallel_services"]
prompt = "Parallel Services"
type = "number"

[[elements]]
condition = "upgrade_strategy == 'canary'"
default = 10
help = "Percentage of traffic to route to canary version"
max = 50
min = 1
name = "canary_percentage"
nickel_path = ["installer", "upgrades", "canary", "traffic_percentage"]
prompt = "Canary Traffic %"
type = "number"

[[elements]]
condition = "upgrade_strategy == 'canary'"
default = 300
help = "Canary test duration in seconds (range: 30-7200)"
max = 7200
min = 30
name = "canary_duration_seconds"
nickel_path = ["installer", "upgrades", "canary", "duration_seconds"]
prompt = "Canary Duration (seconds)"
type = "number"

[[elements]]
condition = "upgrade_strategy == 'maintenance_window'"
default = "sunday"
help = "Day of week for maintenance window"
name = "maintenance_day"
nickel_path = ["installer", "upgrades", "maintenance_window", "day"]
options = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
prompt = "Maintenance Day"
type = "select"

[[elements]]
condition = "upgrade_strategy == 'maintenance_window'"
default = "02:00"
help = "Time of day for maintenance window (HH:MM format, UTC)"
name = "maintenance_time"
nickel_path = ["installer", "upgrades", "maintenance_window", "time"]
prompt = "Maintenance Time (UTC)"
type = "text"

[[elements]]
condition = "upgrade_strategy == 'maintenance_window'"
default = 3600
help = "Maximum duration of maintenance window in seconds (range: 600-86400)"
max = 86400
min = 600
name = "maintenance_duration_seconds"
nickel_path = ["installer", "upgrades", "maintenance_window", "max_duration_seconds"]
prompt = "Max Duration (seconds)"
type = "number"

# Pre-Upgrade Checks
[[elements]]
default = true
help = "Run checks before upgrading"
name = "pre_upgrade_checks_enabled"
nickel_path = ["installer", "upgrades", "pre_checks", "enabled"]
prompt = "Enable Pre-Upgrade Checks"
type = "confirm"

[[elements]]
condition = "pre_upgrade_checks_enabled == true"
default = true
help = "Check disk space requirements"
name = "check_disk_space_for_upgrade"
nickel_path = ["installer", "upgrades", "pre_checks", "check_disk_space"]
prompt = "Check Disk Space"
type = "confirm"

[[elements]]
condition = "pre_upgrade_checks_enabled == true"
default = true
help = "Check service health before upgrade"
name = "check_service_health_pre_upgrade"
nickel_path = ["installer", "upgrades", "pre_checks", "check_service_health"]
prompt = "Check Service Health"
type = "confirm"

[[elements]]
condition = "pre_upgrade_checks_enabled == true"
default = true
help = "Check API/database connectivity"
name = "check_connectivity_pre_upgrade"
nickel_path = ["installer", "upgrades", "pre_checks", "check_connectivity"]
prompt = "Check Connectivity"
type = "confirm"

[[elements]]
condition = "pre_upgrade_checks_enabled == true"
default = true
help = "Validate backup integrity"
name = "validate_backup_integrity"
nickel_path = ["installer", "upgrades", "pre_checks", "validate_backup_integrity"]
prompt = "Validate Backup Integrity"
type = "confirm"

# Backup Before Upgrade
[[elements]]
default = true
help = "Create backup before upgrade"
name = "backup_before_upgrade"
nickel_path = ["installer", "upgrades", "backup_before_upgrade"]
prompt = "Backup Before Upgrade"
type = "confirm"

[[elements]]
condition = "backup_before_upgrade == true"
default = "full"
help = "Type of backup to create"
name = "pre_upgrade_backup_type"
nickel_path = ["installer", "upgrades", "backup_type"]
options = ["full", "incremental", "snapshot"]
prompt = "Backup Type"
type = "select"

[[elements]]
condition = "backup_before_upgrade == true"
default = 30
help = "Backup timeout in minutes"
max = 1440
min = 5
name = "backup_timeout_minutes"
nickel_path = ["installer", "upgrades", "backup_timeout_minutes"]
prompt = "Backup Timeout (minutes)"
type = "number"

# Upgrade Rollback
[[elements]]
default = true
help = "Enable automatic rollback on upgrade failure"
name = "enable_rollback_on_failure"
nickel_path = ["installer", "upgrades", "rollback", "enabled"]
prompt = "Enable Rollback"
type = "confirm"

[[elements]]
condition = "enable_rollback_on_failure == true"
default = "automatic"
help = "Rollback strategy"
name = "rollback_on_failure_strategy"
nickel_path = ["installer", "upgrades", "rollback", "strategy"]
options = ["automatic", "manual", "data_aware"]
prompt = "Rollback Strategy"
type = "select"

[[elements]]
condition = "enable_rollback_on_failure == true"
default = 300
help = "Time to wait after upgrade before validating success (seconds, range: 30-1800)"
max = 1800
min = 30
name = "rollback_validation_delay"
nickel_path = ["installer", "upgrades", "rollback", "validation_delay_seconds"]
prompt = "Validation Delay (seconds)"
type = "number"

[[elements]]
condition = "enable_rollback_on_failure == true"
default = true
help = "Perform database migrations rollback"
name = "rollback_database_migrations"
nickel_path = ["installer", "upgrades", "rollback", "database_migrations"]
prompt = "Rollback DB Migrations"
type = "confirm"

# Service-Specific Upgrades
[[elements]]
default = true
help = "Upgrade Orchestrator service"
name = "upgrade_orchestrator"
nickel_path = ["installer", "upgrades", "services", "orchestrator"]
prompt = "Upgrade Orchestrator"
type = "confirm"

[[elements]]
default = true
help = "Upgrade Control Center service"
name = "upgrade_control_center"
nickel_path = ["installer", "upgrades", "services", "control_center"]
prompt = "Upgrade Control Center"
type = "confirm"

[[elements]]
default = true
help = "Upgrade MCP Server service"
name = "upgrade_mcp_server"
nickel_path = ["installer", "upgrades", "services", "mcp_server"]
prompt = "Upgrade MCP Server"
type = "confirm"

[[elements]]
default = false
help = "Upgrade AI Service"
name = "upgrade_ai_service"
nickel_path = ["installer", "upgrades", "services", "ai_service"]
prompt = "Upgrade AI Service"
type = "confirm"

[[elements]]
default = false
help = "Upgrade RAG Service"
name = "upgrade_rag_service"
nickel_path = ["installer", "upgrades", "services", "rag_service"]
prompt = "Upgrade RAG Service"
type = "confirm"

# Health Checks After Upgrade
[[elements]]
default = true
help = "Run health checks after upgrade completes"
name = "health_checks_post_upgrade"
nickel_path = ["installer", "upgrades", "post_upgrade", "health_checks_enabled"]
prompt = "Health Checks After Upgrade"
type = "confirm"

[[elements]]
condition = "health_checks_post_upgrade == true"
default = 60
help = "Health check interval after upgrade in seconds (range: 5-300)"
max = 300
min = 5
name = "post_upgrade_health_check_interval"
nickel_path = ["installer", "upgrades", "post_upgrade", "health_check_interval_seconds"]
prompt = "Health Check Interval (seconds)"
type = "number"

[[elements]]
condition = "health_checks_post_upgrade == true"
default = 600
help = "Duration to monitor health after upgrade in seconds (range: 60-86400)"
max = 86400
min = 60
name = "post_upgrade_monitoring_duration"
nickel_path = ["installer", "upgrades", "post_upgrade", "monitoring_duration_seconds"]
prompt = "Monitoring Duration (seconds)"
type = "number"

# Version Constraints
[[elements]]
default = false
help = "Enforce version constraints for upgrades"
name = "enable_version_constraints"
nickel_path = ["installer", "upgrades", "version_constraints", "enabled"]
prompt = "Enable Version Constraints"
type = "confirm"

[[elements]]
condition = "enable_version_constraints == true"
default = "compatible"
help = "Version compatibility mode"
name = "version_constraint_mode"
nickel_path = ["installer", "upgrades", "version_constraints", "mode"]
options = ["compatible", "minimum", "maximum", "exact"]
prompt = "Version Constraint Mode"
type = "select"

[[elements]]
condition = "enable_version_constraints == true && version_constraint_mode == 'minimum'"
default = ""
help = "Minimum version to upgrade to (e.g., 3.1.0)"
name = "minimum_version"
nickel_path = ["installer", "upgrades", "version_constraints", "minimum_version"]
prompt = "Minimum Version"
type = "text"

[[elements]]
condition = "enable_version_constraints == true && version_constraint_mode == 'maximum'"
default = ""
help = "Maximum version to upgrade to (e.g., 4.0.0)"
name = "maximum_version"
nickel_path = ["installer", "upgrades", "version_constraints", "maximum_version"]
prompt = "Maximum Version"
type = "text"

# Notification
[[elements]]
default = false
help = "Send notification when upgrade completes"
name = "notify_on_upgrade_complete"
nickel_path = ["installer", "upgrades", "notification", "enabled"]
prompt = "Notify on Upgrade Complete"
type = "confirm"

[[elements]]
condition = "notify_on_upgrade_complete == true"
default = ""
help = "Email address for upgrade completion notification"
name = "upgrade_notification_email"
nickel_path = ["installer", "upgrades", "notification", "email"]
prompt = "Notification Email"
type = "text"
