From 585ae01da68bb091e75ab0c2cf38f503114a043c Mon Sep 17 00:00:00 2001
From: Vika <vika@fireburn.ru>
Date: Wed, 1 Jan 2025 08:18:42 +0300
Subject: PGPASS → PGPASSWORD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Turns out sqlx natively reads a plaintext password from this variable,
otherwise from the `$PGPASSFILE`, otherwise from `$HOME/.pgpass`, so I
don't need custom logic around passwords. Yay for sqlx being smart!

Change-Id: I14858903ea1605469f9ea8095dc3bb056f617e85
---
 src/database/postgres/mod.rs | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

(limited to 'src/database')

diff --git a/src/database/postgres/mod.rs b/src/database/postgres/mod.rs
index 98d9f8d..af19fea 100644
--- a/src/database/postgres/mod.rs
+++ b/src/database/postgres/mod.rs
@@ -48,21 +48,11 @@ impl PostgresStorage {
 impl Storage for PostgresStorage {
     /// Construct a new [`PostgresStorage`] from an URI string and run
     /// migrations on the database.
-    ///
-    /// If `PGPASS_FILE` environment variable is defined, read the
-    /// password from the file at the specified path. If, instead,
-    /// the `PGPASS` environment variable is present, read the
-    /// password from it.
     async fn new(url: &'_ url::Url) -> Result<Self> {
         tracing::debug!("Postgres URL: {url}");
-        let mut options = sqlx::postgres::PgConnectOptions::from_url(url)?
+        let options = sqlx::postgres::PgConnectOptions::from_url(url)?
             .options([("search_path", "kittybox")]);
-        if let Ok(password_file) = std::env::var("PGPASS_FILE") {
-            let password = tokio::fs::read_to_string(password_file).await.unwrap();
-            options = options.password(&password);
-        } else if let Ok(password) = std::env::var("PGPASS") {
-            options = options.password(&password)
-        }
+
         Self::from_pool(
             sqlx::postgres::PgPoolOptions::new()
                 .max_connections(50)
-- 
cgit 1.4.1