Skip to content
5 changes: 5 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ pub async fn oneoff_connection() -> anyhow::Result<AsyncPgConnection> {
pub fn connection_url(config: &config::DbPoolConfig) -> String {
let mut url = Url::parse(config.url.expose_secret()).expect("Invalid database URL");

// Support `postgres:///db_name` shorthand for easier local development.
if url.host().is_none() {
maybe_append_url_param(&mut url, "host", "/run/postgresql");
}
Comment on lines +29 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while I'm okay with this default for the testing setup, I'm not sure we want to use the same for production. Is there anything preventing you from specifying /run/postgresql directly in the DATABASE_URL env var?


if config.enforce_tls {
maybe_append_url_param(&mut url, "sslmode", "require");
}
Expand Down
Loading