Configuration-driven database adapter management.
This namespace provides functionality to read database configuration from config.edn and only load adapters that are marked as :active. This allows for optimized deployments where only required database drivers are loaded.
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.config :as db-config])
(db-config/get-active-adapters "dev") ; Get active adapters for dev env (db-config/adapter-active? :postgresql) ; Check if adapter is active
Configuration-driven database adapter management. This namespace provides functionality to read database configuration from config.edn and only load adapters that are marked as :active. This allows for optimized deployments where only required database drivers are loaded. Key Features: - Configuration-driven adapter loading - Environment-specific database configs - Graceful handling of inactive adapters - JDBC driver optimization (only load needed drivers) Usage: (require '[wagoe.platform.shell.adapters.database.config :as db-config]) (db-config/get-active-adapters "dev") ; Get active adapters for dev env (db-config/adapter-active? :postgresql) ; Check if adapter is active
Cache for loaded configurations to avoid repeated file reads
Cache for loaded configurations to avoid repeated file reads
(adapter-active? adapter-type env)Check if a specific adapter type is active in environment
Check if a specific adapter type is active in environment
(clear-config-cache!)Clear configuration cache (useful for testing)
Clear configuration cache (useful for testing)
(config->db-config config-key config)Convert configuration entry to database adapter config
Convert configuration entry to database adapter config
(config-summary env)Get summary of database configuration for environment
Get summary of database configuration for environment
(detect-environment)Detect current environment from various sources, with the aliases the
config loader accepts resolved: development is dev (BOU-585).
Detect current environment from various sources, with the aliases the config loader accepts resolved: `development` is `dev` (BOU-585).
(disposable-environment? env)True when env names a database that is safe to seed.
Callers must pass the environment resolved by detect-environment, not a
direct read of WAG_ENV — the connection uses the full precedence chain
(-Denv > WAG_ENV > ENV > ENVIRONMENT), and a guard that asks a narrower
question than the connection is not a guard.
True when `env` names a database that is safe to seed. Callers must pass the environment resolved by `detect-environment`, not a direct read of WAG_ENV — the connection uses the full precedence chain (-Denv > WAG_ENV > ENV > ENVIRONMENT), and a guard that asks a narrower question than the connection is not a guard.
The profiles whose database may be seeded: resettable-envs.
The profiles whose database may be seeded: `resettable-envs`.
(get-active-adapters env)Get list of active database adapter types for environment
Get list of active database adapter types for environment
(get-active-adapters-from-config config-map)Get active adapter configurations from config map
Get active adapter configurations from config map
(get-active-db-config)Get the first active database configuration for environment.
This is used by the migration system which operates on a single database. If multiple databases are configured, returns the first one.
Args: None (uses detected environment)
Returns: Database adapter configuration map with :datasource
Throws: Exception if no active database is configured
Get the first active database configuration for environment. This is used by the migration system which operates on a single database. If multiple databases are configured, returns the first one. Args: None (uses detected environment) Returns: Database adapter configuration map with :datasource Throws: Exception if no active database is configured
(get-active-db-configs env)Get database adapter configurations for all active databases in environment
Get database adapter configurations for all active databases in environment
(get-all-database-configs config-map)Get all database configurations (active + inactive) from config map
Get all database configurations (active + inactive) from config map
(get-database-configs env)Get database configurations for environment
Get database configurations for environment
(get-inactive-adapters config-map)Get inactive adapter configurations from config map
Get inactive adapter configurations from config map
(getenv k)Environment variable lookup. Exists as a var (rather than inline interop) so tests can redef it — env vars cannot be modified inside a JVM.
Environment variable lookup. Exists as a var (rather than inline interop) so tests can redef it — env vars cannot be modified inside a JVM.
(load-config env)Load configuration for environment with caching
Load configuration for environment with caching
(merge-configs base-config override-config)Merge two configuration maps
Merge two configuration maps
(print-config-summary env)Print formatted configuration summary for debugging
Print formatted configuration summary for debugging
Why a reset was refused, and what to do instead.
Why a reset was refused, and what to do instead.
(resettable-environment? env)True when env, as detect-environment resolves it, may be reset.
True when `env`, as `detect-environment` resolves it, may be reset.
The profiles db:reset may drop every table in, and db:seed may fill:
one allowlist, so a profile that can be reset can be seeded again
(BOU-588). Anything else — prod, an unknown name, a blank one — changes its
schema through migrations. Compare against detect-environment, which
resolves aliases.
The profiles `db:reset` may drop every table in, and `db:seed` may fill: one allowlist, so a profile that can be reset can be seeded again (BOU-588). Anything else — prod, an unknown name, a blank one — changes its schema through migrations. Compare against `detect-environment`, which resolves aliases.
(valid-adapter-config? adapter-key config)Validate adapter configuration (wrapper for validate-adapter-config)
Validate adapter configuration (wrapper for validate-adapter-config)
(valid-config-structure? config)Validate that config has required structure
Validate that config has required structure
(validate-adapter-config adapter-type config)Validate that an adapter configuration has required keys
Validate that an adapter configuration has required keys
(validate-database-configs env)Validate all database configurations for environment
Validate all database configurations for environment
(with-environment env f)Execute function with specific environment context
Execute function with specific environment context
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |