# Installer Database Configuration Fragment

[[elements]]
border_bottom = false
border_top = true
name = "database_section_header"
title = "🗄️ Database Configuration"
type = "section_header"

# Database Initialization
[[elements]]
default = true
help = "Automatically initialize databases during installation"
name = "auto_init_database"
nickel_path = ["installer", "database", "auto_init"]
prompt = "Auto-Initialize Database"
type = "confirm"

[[elements]]
condition = "auto_init_database == true"
default = true
help = "Run migrations automatically during installation"
name = "auto_migrate"
nickel_path = ["installer", "database", "auto_migrate"]
prompt = "Auto-Migrate"
type = "confirm"

[[elements]]
condition = "auto_init_database == true"
default = true
help = "Create default database schema and tables"
name = "create_schema"
nickel_path = ["installer", "database", "create_schema"]
prompt = "Create Schema"
type = "confirm"

# Migration Settings
[[elements]]
condition = "auto_migrate == true"
default = "/var/lib/provisioning/migrations"
help = "Directory containing database migration files"
name = "migrations_directory"
nickel_path = ["installer", "database", "migrations", "directory"]
prompt = "Migrations Directory"
type = "text"

[[elements]]
condition = "auto_migrate == true"
default = "auto"
help = "Migration version strategy"
name = "migration_strategy"
nickel_path = ["installer", "database", "migrations", "strategy"]
options = ["auto", "manual", "sequential"]
prompt = "Migration Strategy"
type = "select"

[[elements]]
condition = "auto_migrate == true"
default = 300
help = "Migration timeout in seconds"
min = 30
name = "migration_timeout_seconds"
nickel_path = ["installer", "database", "migrations", "timeout_seconds"]
prompt = "Migration Timeout (seconds)"
type = "number"

# Database Backup
[[elements]]
default = true
help = "Create database backup before installation/upgrade"
name = "backup_before_install"
nickel_path = ["installer", "database", "backup", "before_install"]
prompt = "Backup Before Install"
type = "confirm"

[[elements]]
condition = "backup_before_install == true"
default = "/var/backups/provisioning"
help = "Directory for database backups"
name = "backup_directory"
nickel_path = ["installer", "database", "backup", "directory"]
prompt = "Backup Directory"
type = "text"

[[elements]]
condition = "backup_before_install == true"
default = "full"
help = "Backup type"
name = "backup_type"
nickel_path = ["installer", "database", "backup", "type"]
options = ["full", "incremental", "differential"]
prompt = "Backup Type"
type = "select"

[[elements]]
condition = "backup_before_install == true"
default = true
help = "Compress database backups"
name = "compress_backups"
nickel_path = ["installer", "database", "backup", "compress"]
prompt = "Compress Backups"
type = "confirm"

[[elements]]
condition = "backup_before_install == true"
default = 7
help = "Backup retention in days"
max = 365
min = 1
name = "backup_retention_days"
nickel_path = ["installer", "database", "backup", "retention_days"]
prompt = "Backup Retention (days)"
type = "number"

# Database Verification
[[elements]]
default = true
help = "Verify database integrity after installation"
name = "verify_database"
nickel_path = ["installer", "database", "verification", "enabled"]
prompt = "Verify Database"
type = "confirm"

[[elements]]
condition = "verify_database == true"
default = true
help = "Check database consistency"
name = "check_consistency"
nickel_path = ["installer", "database", "verification", "check_consistency"]
prompt = "Check Consistency"
type = "confirm"

[[elements]]
condition = "verify_database == true"
default = true
help = "Check for missing indices"
name = "check_indices"
nickel_path = ["installer", "database", "verification", "check_indices"]
prompt = "Check Indices"
type = "confirm"

[[elements]]
condition = "verify_database == true"
default = true
help = "Validate foreign key relationships"
name = "check_foreign_keys"
nickel_path = ["installer", "database", "verification", "check_foreign_keys"]
prompt = "Check Foreign Keys"
type = "confirm"

# Data Seeding
[[elements]]
default = false
help = "Seed database with sample data"
name = "seed_database"
nickel_path = ["installer", "database", "seeding", "enabled"]
prompt = "Seed Database"
type = "confirm"

[[elements]]
condition = "seed_database == true"
default = "minimal"
help = "Sample data size"
name = "seed_data_size"
nickel_path = ["installer", "database", "seeding", "data_size"]
options = ["minimal", "standard", "large"]
prompt = "Seed Data Size"
type = "select"

[[elements]]
condition = "seed_database == true"
default = "seeding-data.sql"
help = "SQL file containing seed data"
name = "seed_data_file"
nickel_path = ["installer", "database", "seeding", "data_file"]
prompt = "Seed Data File"
type = "text"

# Database Pooling
[[elements]]
default = 10
help = "Database connection pool size (range: 1-100)"
max = 100
min = 1
name = "connection_pool_size"
nickel_path = ["installer", "database", "pool_size"]
prompt = "Connection Pool Size"
type = "number"

[[elements]]
default = 300
help = "Connection pool timeout in seconds (range: 10-3600)"
max = 3600
min = 10
name = "connection_pool_timeout"
nickel_path = ["installer", "database", "pool_timeout_seconds"]
prompt = "Pool Timeout (seconds)"
type = "number"

[[elements]]
default = 3600
help = "Connection idle timeout in seconds (range: 60-14400)"
max = 14400
min = 60
name = "connection_idle_timeout"
nickel_path = ["installer", "database", "idle_timeout_seconds"]
prompt = "Idle Timeout (seconds)"
type = "number"

# Database Optimization
[[elements]]
default = false
help = "Optimize database after installation"
name = "optimize_database"
nickel_path = ["installer", "database", "optimization", "enabled"]
prompt = "Optimize Database"
type = "confirm"

[[elements]]
condition = "optimize_database == true"
default = true
help = "Analyze query statistics"
name = "analyze_statistics"
nickel_path = ["installer", "database", "optimization", "analyze_statistics"]
prompt = "Analyze Statistics"
type = "confirm"

[[elements]]
condition = "optimize_database == true"
default = true
help = "Rebuild indices"
name = "rebuild_indices"
nickel_path = ["installer", "database", "optimization", "rebuild_indices"]
prompt = "Rebuild Indices"
type = "confirm"

[[elements]]
condition = "optimize_database == true"
default = true
help = "Vacuum database (reclaim space)"
name = "vacuum_database"
nickel_path = ["installer", "database", "optimization", "vacuum"]
prompt = "Vacuum Database"
type = "confirm"
