diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,4 @@ requests sentry-sdk typing-extensions +psycopg2 diff --git a/swh/web/config.py b/swh/web/config.py --- a/swh/web/config.py +++ b/swh/web/config.py @@ -94,7 +94,7 @@ "scheduler": ("dict", {"cls": "remote", "url": "http://127.0.0.1:5008/"}), "development_db": ("string", os.path.join(SETTINGS_DIR, "db.sqlite3")), "test_db": ("string", os.path.join(SETTINGS_DIR, "testdb.sqlite3")), - "production_db": ("string", "/var/lib/swh/web.sqlite3"), + "production_db": ("dict", {"name": "swh-web"}), "deposit": ( "dict", { diff --git a/swh/web/settings/common.py b/swh/web/settings/common.py --- a/swh/web/settings/common.py +++ b/swh/web/settings/common.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 The Software Heritage developers +# Copyright (C) 2017-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -96,7 +96,7 @@ DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", - "NAME": swh_web_config["development_db"], + "NAME": swh_web_config.get("development_db", ""), } } diff --git a/swh/web/settings/production.py b/swh/web/settings/production.py --- a/swh/web/settings/production.py +++ b/swh/web/settings/production.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -31,10 +31,17 @@ # We're going through seven (or, in that case, 2) proxies thanks to Varnish REST_FRAMEWORK["NUM_PROXIES"] = 2 +db_conf = swh_web_config["production_db"] + +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": swh_web_config["production_db"], + "ENGINE": "django.db.backends.postgresql", + "NAME": db_conf.get("name"), + "HOST": db_conf.get("host"), + "PORT": db_conf.get("port"), + "USER": db_conf.get("user"), + "PASSWORD": db_conf.get("password"), } }