From 7daa1c654375cfd2c0bbb5784e580c600cebfa35 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 13 Mar 2025 12:11:58 +0000 Subject: [PATCH] Document environment variable for database url (#5501) --- config/defaults.hjson | 12 ++++-------- crates/utils/src/settings/structs.rs | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/config/defaults.hjson b/config/defaults.hjson index 7b34f38b0..239caff07 100644 --- a/config/defaults.hjson +++ b/config/defaults.hjson @@ -1,15 +1,11 @@ { # settings related to the postgresql database database: { - # Configure the database by specifying URI pointing to a postgres instance + # Configure the database by specifying URI pointing to a postgres instance. This parameter can + # also be set by environment variable `LEMMY_DATABASE_URL`. # - # This example uses peer authentication to obviate the need for creating, - # configuring, and managing passwords. - # - # For an explanation of how to use connection URIs, see [here][0] in - # PostgreSQL's documentation. - # - # [0]: https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6 + # For an explanation of how to use connection URIs, see PostgreSQL's documentation: + # https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6 connection: "postgres://lemmy:password@localhost:5432/lemmy" # Maximum number of active sql connections pool_size: 30 diff --git a/crates/utils/src/settings/structs.rs b/crates/utils/src/settings/structs.rs index 1ab5b64da..abf01984f 100644 --- a/crates/utils/src/settings/structs.rs +++ b/crates/utils/src/settings/structs.rs @@ -143,15 +143,11 @@ pub enum PictrsImageMode { #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)] #[serde(default, deny_unknown_fields)] pub struct DatabaseConfig { - /// Configure the database by specifying URI pointing to a postgres instance + /// Configure the database by specifying URI pointing to a postgres instance. This parameter can + /// also be set by environment variable `LEMMY_DATABASE_URL`. /// - /// This example uses peer authentication to obviate the need for creating, - /// configuring, and managing passwords. - /// - /// For an explanation of how to use connection URIs, see [here][0] in - /// PostgreSQL's documentation. - /// - /// [0]: https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6 + /// For an explanation of how to use connection URIs, see PostgreSQL's documentation: + /// https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6 #[default("postgres://lemmy:password@localhost:5432/lemmy")] #[doku(example = "postgresql:///lemmy?user=lemmy&host=/var/run/postgresql")] pub(crate) connection: String,