From e9d39dfb5c3974fd43b297ac6da0eac8e633a0c9 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Mon, 16 Oct 2023 13:54:17 +0200 Subject: [PATCH] feat: Ensure that PostgreSQL database uses 'UTC' timezone The application stores the datatime objects in a timezone naive format. Therefore, we store them as UTC and also expect to get UTC as response. We expect the database to run in UTC, it should not perform any additional datetime or timezone transformation. The transformation is done in the application. However, some databases run in different timezones. In this case, we ensure that UTC is used for our transactions. --- backend/capellacollab/core/database/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/capellacollab/core/database/__init__.py b/backend/capellacollab/core/database/__init__.py index 12d6a7b91..e88ae49e4 100644 --- a/backend/capellacollab/core/database/__init__.py +++ b/backend/capellacollab/core/database/__init__.py @@ -11,7 +11,8 @@ from capellacollab.config import config engine = sa.create_engine( - config["database"]["url"], connect_args={"connect_timeout": 5} + config["database"]["url"], + connect_args={"connect_timeout": 5, "options": "-c timezone=utc"}, ) SessionLocal = orm.sessionmaker(autocommit=False, autoflush=False, bind=engine)