add new app
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
2026-06-22 10:28:56 +01:00
parent 956e7fc1d0
commit 5d26a4dd05
10 changed files with 73 additions and 3 deletions
+9 -3
View File
@@ -10,6 +10,8 @@ class ProjectDatabaseRouter:
"""Attempts to read simpsons and cloudmanager models go to their specific dbs."""
if model._meta.app_label == 'simpsons':
return 'simpsons_db'
if model._meta.app_label == 'job':
return 'job_db'
if model._meta.app_label == 'redirect':
return 'redirect_db'
if model._meta.app_label == 'cloudmanager':
@@ -20,6 +22,8 @@ class ProjectDatabaseRouter:
"""Attempts to write simpsons and cloudmanager models go to their specific dbs."""
if model._meta.app_label == 'simpsons':
return 'simpsons_db'
if model._meta.app_label == 'job':
return 'job_db'
if model._meta.app_label == 'cloudmanager':
return 'cloudmanager_db'
if model._meta.app_label == 'redirect':
@@ -30,8 +34,8 @@ class ProjectDatabaseRouter:
"""Allow relations if both models are in the same database."""
# Prevents accidental foreign key relationships across different physical DBs
if (
obj1._meta.app_label in ['simpsons', 'cloudmanager','redirect'] or
obj2._meta.app_label in ['simpsons', 'cloudmanager','redirect']
obj1._meta.app_label in ['simpsons', 'cloudmanager','redirect','job'] or
obj2._meta.app_label in ['simpsons', 'cloudmanager','redirect','job']
):
return obj1._meta.app_label == obj2._meta.app_label
return None
@@ -40,12 +44,14 @@ class ProjectDatabaseRouter:
"""Ensure the app's models only show up in the designated database."""
if app_label == 'simpsons':
return db == 'simpsons_db'
if app_label == 'job':
return db == 'job_db'
if app_label == 'cloudmanager':
return db == 'cloudmanager_db'
if app_label == 'redirect':
return 'redirect_db'
# Ensure default Django apps (auth, sessions, etc.) don't migrate into simpsons/cloudmanager
if db in ['simpsons_db', 'cloudmanager_db','redirect_db']:
if db in ['simpsons_db', 'cloudmanager_db','redirect_db','job_db']:
return False
return None
+9
View File
@@ -46,6 +46,7 @@ INSTALLED_APPS = [
'apps.cloudmanager.apps.CloudmanagerConfig',
'apps.random_simpsons.apps.RandomSimpsonsConfig',
'apps.website_redirection.apps.redirectConfig',
'apps.job_dashboard.apps.JobDashboardConfig',
'import_export',
]
@@ -124,6 +125,14 @@ DATABASES = {
'HOST': os.environ.get('DB_HOST'),
'PORT': os.environ.get('DB_PORT'),
},
'job_db': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'job',
'USER': os.environ.get('DB_USERNAME'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOST'),
'PORT': os.environ.get('DB_PORT'),
},
}
DATABASE_ROUTERS = ['core.routers.ProjectDatabaseRouter']
#DATABASE_ROUTERS = []