# PostgreSQL database configuration fragment
# Conditional: when database_type == "postgres"

[[elements]]
type = "text"
name = "postgres_host"
prompt = "PostgreSQL host"
help = "Hostname or IP address of PostgreSQL server"
default = "localhost"
nickel_path = ["provisioning", "database", "postgres", "host"]
required = true
when = "database_type == postgres"

[[elements]]
type = "custom"
custom_type = "u16"
name = "postgres_port"
prompt = "PostgreSQL port"
help = "Port number for PostgreSQL server"
default = "5432"
minimum = "1024"
maximum = "65535"
nickel_path = ["provisioning", "database", "postgres", "port"]
required = true
when = "database_type == postgres"

[[elements]]
type = "text"
name = "postgres_database"
prompt = "Database name"
help = "PostgreSQL database name"
placeholder = "myapp"
nickel_path = ["provisioning", "database", "postgres", "database"]
required = true
when = "database_type == postgres"
validation_pattern = "^[a-zA-Z0-9_]+$"

[[elements]]
type = "text"
name = "postgres_username"
prompt = "Database username"
help = "PostgreSQL username for authentication"
default = "postgres"
nickel_path = ["provisioning", "database", "postgres", "username"]
required = true
when = "database_type == postgres"

[[elements]]
type = "password"
name = "postgres_password"
prompt = "Database password"
help = "PostgreSQL password (min 8 characters)"
nickel_path = ["provisioning", "database", "postgres", "password"]
required = true
when = "database_type == postgres"

[[elements]]
type = "custom"
custom_type = "u16"
name = "postgres_pool_size"
prompt = "Connection pool size"
help = "Maximum number of database connections (1-1000)"
default = "10"
minimum = "1"
maximum = "1000"
nickel_path = ["provisioning", "database", "postgres", "pool_size"]
required = true
when = "database_type == postgres"

[[elements]]
type = "custom"
custom_type = "u16"
name = "postgres_connection_timeout"
prompt = "Connection timeout (seconds)"
help = "Timeout for establishing database connections (1-300)"
default = "30"
minimum = "1"
maximum = "300"
nickel_path = ["provisioning", "database", "postgres", "connection_timeout"]
required = true
when = "database_type == postgres"

[[elements]]
type = "select"
name = "postgres_ssl_mode"
prompt = "SSL mode"
help = "PostgreSQL SSL connection mode"
options = ["disable", "allow", "prefer", "require", "verify-ca", "verify-full"]
default = "prefer"
nickel_path = ["provisioning", "database", "postgres", "ssl_mode"]
required = true
when = "database_type == postgres"
