Skip to content

Commit c3bb706

Browse files
committed
feat: configure database settings for testing and production environments
1 parent fed055c commit c3bb706

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

todo_project/settings/base.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,28 @@
162162
}
163163

164164
# Database Configuration
165-
DATABASES = {
166-
"default": {
167-
"ENGINE": "django.db.backends.postgresql",
168-
"NAME": POSTGRES_NAME,
169-
"USER": POSTGRES_USER,
170-
"PASSWORD": POSTGRES_PASSWORD,
171-
"HOST": POSTGRES_HOST,
172-
"PORT": POSTGRES_PORT,
173-
"OPTIONS": {
174-
"sslmode": "prefer",
175-
},
165+
# Only configure PostgreSQL if not in testing mode
166+
if not TESTING:
167+
DATABASES = {
168+
"default": {
169+
"ENGINE": "django.db.backends.postgresql",
170+
"NAME": POSTGRES_NAME,
171+
"USER": POSTGRES_USER,
172+
"PASSWORD": POSTGRES_PASSWORD,
173+
"HOST": POSTGRES_HOST,
174+
"PORT": POSTGRES_PORT,
175+
"OPTIONS": {
176+
"sslmode": "prefer",
177+
},
178+
}
179+
}
180+
else:
181+
DATABASES = {
182+
"default": {
183+
"ENGINE": "django.db.backends.sqlite3",
184+
"NAME": ":memory:",
185+
}
176186
}
177-
}
178187

179188
# Dual-Write Configuration
180189
DUAL_WRITE_ENABLED = os.getenv("DUAL_WRITE_ENABLED", "True").lower() == "true"

0 commit comments

Comments
 (0)