Skip to content

Commit

Permalink
Add new app and models
Browse files Browse the repository at this point in the history
Add new app and models
  • Loading branch information
DJensen94 committed Jan 8, 2025
1 parent 5a56918 commit e8add49
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 0 deletions.
Empty file.
32 changes: 32 additions & 0 deletions backend/src/xfd_django/xfd_django/db_routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class MyAppRouter:
def db_for_read(self, model, **hints):
# Specify the app you want to route to the mini_data_lake database
if model._meta.app_label == 'dmz_mini_dl':
return 'mini_data_lake'
return 'default' # All other models go to the default database

def db_for_write(self, model, **hints):
if model._meta.app_label == 'dmz_mini_dl':
return 'mini_data_lake'
return 'default' # All other models go to the default database

def allow_relation(self, obj1, obj2, **hints):
# Check the app labels of both objects
app_label1 = obj1._meta.app_label
app_label2 = obj2._meta.app_label

# If both objects are from the specific app, allow the relation
if app_label1 == 'dmz_mini_dl' and app_label2 == 'dmz_mini_dl':
return True

# If only one of them is from the specific app, disallow the relation
if app_label1 == 'dmz_mini_dl' or app_label2 == 'dmz_mini_dl':
return False

# Allow relations between all other models
return True

def allow_migrate(self, db, app_label, model_name=None, **hints):
if app_label == 'dmz_mini_dl':
return db == 'mini_data_lake' # Migrate the specific app to the mini_data_lake database
return db == 'default' # All other apps migrate to the default database
10 changes: 10 additions & 0 deletions backend/src/xfd_django/xfd_django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,19 @@
"TEST": {
"NAME": "crossfeed_test", # Name of the test database
},
},
"mini_data_lake": {
'ENGINE': "django.db.backends.postgresql_psycopg2", # Replace with your database engine
'NAME': os.getenv("mdl_database"),
'USER': os.getenv('mdl_user'),
'PASSWORD': os.getenv('mdl_password'),
'HOST': os.getenv('mdl_host'),
'PORT': os.getenv('mdl_port'),
}
}

DATABASE_ROUTERS = ['xfd_django.db_routers.MyAppRouter']

# ElastiCache AWS
ELASTICACHE_ENDPOINT = os.getenv("ELASTICACHE_ENDPOINT")

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions backend/src/xfd_django/xfd_mini_dl/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions backend/src/xfd_django/xfd_mini_dl/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class XfdMiniDlConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'xfd_mini_dl'
Empty file.
3 changes: 3 additions & 0 deletions backend/src/xfd_django/xfd_mini_dl/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions backend/src/xfd_django/xfd_mini_dl/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions backend/src/xfd_django/xfd_mini_dl/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.

0 comments on commit e8add49

Please sign in to comment.