fix: database.url config takes precedence over DATABASE_URL env var#309
Conversation
The DATABASE_URL env var was unconditionally overriding database.url from the config file. It is now only used as a fallback when database.url is not set. Also add Default derive to DatabaseSettings and serde(default) to the database field so the section can be omitted entirely. Agent-Logs-Url: https://github.com/rise-deploy/rise/sessions/ffd4f056-2685-448e-a57e-5ee6f771fbe3 Co-authored-by: NiklasRosenstein <1318438+NiklasRosenstein@users.noreply.github.com>
database.url config takes precedence over DATABASE_URL env var
NiklasRosenstein
left a comment
There was a problem hiding this comment.
@copilot Does SQLX understand the database.url setting? I don't see how we tell SQLX about that URL at runtime.
Yes — let db_pool = PgPoolOptions::new()
.max_connections(10)
.connect(&settings.database.url) // ← uses the resolved config value
.await
.context("Failed to connect to PostgreSQL")?;
|
|
@copilot Great. The we should find a real good place to document that |
Agent-Logs-Url: https://github.com/rise-deploy/rise/sessions/3e18260b-64d0-402a-917e-36da45b3e65d Co-authored-by: NiklasRosenstein <1318438+NiklasRosenstein@users.noreply.github.com>
Done in 0a9dd96. Added a "DATABASE_URL at Compile Time" subsection to the SQLX section in |
|
Docs preview: Updated for commit |
The database section is now optional (#[serde(default)]), so it is no longer in the schema's required list. Regenerated to keep the committed schema in sync, which CI verifies via config:schema:check. https://claude.ai/code/session_01TmD3FqbNZqmKsM36WmJzxD
database.urlconfig taking precedence overDATABASE_URLenv var insrc/server/settings.rsdocs/engineering/…/configuration.mdto reflect corrected precedenceDATABASE_URL at Compile Timesection todocs/engineering/…/developer-guide.mdexplaining thatDATABASE_URLis required at compile time for SQLx query verification (with example commands), and that the runtime URL comes fromsettings.database.urlconfiguration.mdnote to cross-reference the developer guide instead of restating the compile-time detail