From cdcf5cf8a65eaeaf12a7cbed8c8d7ef5a7668f58 Mon Sep 17 00:00:00 2001 From: Nico Virkki Date: Mon, 14 Oct 2024 10:51:13 +0300 Subject: [PATCH] chore(db-con): use database password if present in env Use the DATABASE_PASSWORD environment variable if it exists and use it in database connection. This is the way. Refs RATY-129 --- hauki/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hauki/settings.py b/hauki/settings.py index 5451ac8c..111a2365 100644 --- a/hauki/settings.py +++ b/hauki/settings.py @@ -51,6 +51,7 @@ def get_git_revision_hash() -> str: SYSTEM_DATA_SOURCE_ID=(str, "hauki"), LANGUAGES=(list, ["fi", "sv", "en"]), DATABASE_URL=(str, "postgres:///hauki"), + DATABASE_PASSWORD=(str, ""), TEST_DATABASE_URL=(str, ""), TOKEN_AUTH_ACCEPTED_AUDIENCE=(str, ""), TOKEN_AUTH_SHARED_SECRET=(str, ""), @@ -100,6 +101,9 @@ def get_git_revision_hash() -> str: if env("TEST_DATABASE_URL"): DATABASES["default"]["TEST"] = env.db("TEST_DATABASE_URL") +if env("DATABASE_PASSWORD"): + DATABASES["default"]["PASSWORD"] = env("DATABASE_PASSWORD") + DEFAULT_AUTO_FIELD = "django.db.models.AutoField" AUTH_USER_MODEL = "users.User"