# Database Backend Selection Fragment
# This fragment allows selecting the appropriate database backend (RocksDB, SurrealDB, PostgreSQL)
# Based on the selection, include the corresponding database-*-section.toml fragment

[[elements]]
border_top = true
border_bottom = false
name = "database_backend_selection_header"
title = "🗄️ Database Backend Selection"
type = "section_header"

[[elements]]
default = "rocksdb"
help = "Select the database backend for this service"
name = "database_backend_selection"
nickel_path = ["database", "backend_type"]
options = ["rocksdb", "surrealdb_embedded", "surrealdb_server", "postgresql"]
prompt = "Database Backend"
required = true
type = "select"

# Backend Descriptions
[[elements]]
condition = "database_backend_selection == 'rocksdb'"
default = false
help = "RocksDB: Embedded key-value store. Zero external dependencies, local filesystem storage, good for solo/multiuser modes. Limited to single instance."
name = "rocksdb_info"
type = "info"
prompt = "RocksDB Info"

[[elements]]
condition = "database_backend_selection == 'surrealdb_embedded'"
default = false
help = "SurrealDB (Embedded): In-process SurrealDB. No external server needed, queryable JSON/SQL, suitable for small to medium deployments."
name = "surrealdb_embedded_info"
type = "info"
prompt = "SurrealDB Embedded Info"

[[elements]]
condition = "database_backend_selection == 'surrealdb_server'"
default = false
help = "SurrealDB (Server): External SurrealDB server. Scalable multi-instance, HA ready, suitable for multiuser/enterprise modes."
name = "surrealdb_server_info"
type = "info"
prompt = "SurrealDB Server Info"

[[elements]]
condition = "database_backend_selection == 'postgresql'"
default = false
help = "PostgreSQL: Traditional RDBMS. Proven stability, full ACID, complex queries, suitable for enterprise with HA via replication."
name = "postgresql_info"
type = "info"
prompt = "PostgreSQL Info"

# Backend Selection Guidelines
[[elements]]
name = "backend_selection_guide"
type = "section_header"
title = "Backend Selection Guide"
border_top = true
border_bottom = true

[[elements]]
condition = "deployment_mode == 'solo'"
default = false
help = "Recommended for Solo: RocksDB (simplest) or SurrealDB Embedded (more features, same simplicity)"
name = "solo_recommendation"
type = "info"
prompt = "Solo Recommendation"

[[elements]]
condition = "deployment_mode == 'multiuser'"
default = false
help = "Recommended for MultiUser: SurrealDB Server (scalable, easy clustering) or PostgreSQL (if you need traditional RDBMS)"
name = "multiuser_recommendation"
type = "info"
prompt = "MultiUser Recommendation"

[[elements]]
condition = "deployment_mode == 'cicd'"
default = false
help = "Recommended for CI/CD: SurrealDB Embedded (ephemeral, no external deps) or RocksDB (fastest)"
name = "cicd_recommendation"
type = "info"
prompt = "CI/CD Recommendation"

[[elements]]
condition = "deployment_mode == 'enterprise'"
default = false
help = "Recommended for Enterprise: SurrealDB Server HA (native clustering) or PostgreSQL with replication + external backup service"
name = "enterprise_recommendation"
type = "info"
prompt = "Enterprise Recommendation"
