refactor: remove conditional sqlite fallback and force postgresql database configuration
Some checks failed
Deploy Beta (NATIVE) / deploy (push) Failing after 19s

This commit is contained in:
vickytechkey 2026-09-06 21:18:52 +05:30
parent 757cbc85ae
commit a3be8f0e6d

View file

@ -87,56 +87,33 @@ WSGI_APPLICATION = 'config.wsgi.application'
# ---------------------------------------------------------------------------
# Database Configuration
# ---------------------------------------------------------------------------
import socket
def is_postgres_available():
try:
s = socket.create_connection(('127.0.0.1', 5432), timeout=1)
s.close()
return True
except OSError:
return False
import os
if is_postgres_available():
db_credentials = {
'ENGINE': 'django.db.backends.postgresql',
'USER': os.environ.get('DB_USER', 'vignesh'),
'PASSWORD': os.environ.get('DB_PASSWORD', 'vtechnosoft@123A'),
'HOST': os.environ.get('DB_HOST', '127.0.0.1'),
'PORT': os.environ.get('DB_PORT', '5432'),
}
db_credentials = {
'ENGINE': 'django.db.backends.postgresql',
'USER': os.environ.get('DB_USER', 'vignesh'),
'PASSWORD': os.environ.get('DB_PASSWORD', 'vtechnosoft@123A'),
'HOST': os.environ.get('DB_HOST', '127.0.0.1'),
'PORT': os.environ.get('DB_PORT', '5432'),
}
env_name = os.environ.get('ENVIRONMENT', 'prod')
db_suffix = f'_{env_name}'
env_name = os.environ.get('ENVIRONMENT', 'prod')
db_suffix = f'_{env_name}'
DATABASES = {
'default': {
'NAME': f'sellerprofile{db_suffix}',
**db_credentials
},
'customerprofile': {
'NAME': f'customerprofile{db_suffix}',
**db_credentials
},
'productprofile': {
'NAME': f'productprofile{db_suffix}',
**db_credentials
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
},
'customerprofile': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
},
'productprofile': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
DATABASES = {
'default': {
'NAME': f'sellerprofile{db_suffix}',
**db_credentials
},
'customerprofile': {
'NAME': f'customerprofile{db_suffix}',
**db_credentials
},
'productprofile': {
'NAME': f'productprofile{db_suffix}',
**db_credentials
}
}
DATABASE_ROUTERS = ['config.db_router.DatabaseRouter']