Skip to content

Commit

Permalink
db settings
Browse files Browse the repository at this point in the history
  • Loading branch information
benthuffine committed Aug 25, 2023
1 parent dbcf5aa commit 6207287
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,19 @@ jobs:
pip freeze
- name: Run tests
env:
DB_SETTINGS: >-
DB_SETTINGS_ONE: >-
{
"ENGINE":"django.db.backends.postgresql",
"NAME":"dynamic_db_router",
"NAME":"dynamic_db_router_one",
"USER":"postgres",
"PASSWORD":"postgres",
"HOST":"localhost",
"PORT":"5432"
}
DB_SETTINGS_TWO: >-
{
"ENGINE":"django.db.backends.postgresql",
"NAME":"dynamic_db_router_two",
"USER":"postgres",
"PASSWORD":"postgres",
"HOST":"localhost",
Expand Down
9 changes: 9 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ def configure_settings():
else:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))

# Check env for db override (used for github actions)
if os.environ.get('DB_SETTINGS_ONE'):
db_config_one = json.loads(os.environ.get('DB_SETTINGS_ONE'))

# Check env for db override (used for github actions)
if os.environ.get('DB_SETTINGS_TWO'):
db_config_two = json.loads(os.environ.get('DB_SETTING_TWO'))


settings.configure(
DATABASES={
'default': db_config_one,
Expand Down

0 comments on commit 6207287

Please sign in to comment.