Skip to content

Commit

Permalink
Make db config common
Browse files Browse the repository at this point in the history
  • Loading branch information
snnbotchway committed Jun 26, 2023
1 parent 5d3de66 commit a2e10c2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: cp .env.dist .env
working-directory: ./app/

# TODO: Uncomment after writing some tests
# TODO: Uncomment after writing some tests, since pytest exits with a non-zero code if there are no tests.
# - name: Test
# run: docker compose run --rm app sh -c pytest
# working-directory: ./app/
Expand Down
1 change: 1 addition & 0 deletions app/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgres://postgres:change_me@db:5432/devdb
9 changes: 9 additions & 0 deletions app/storeroom/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
USE_TZ = True


# Parse database connection url strings
# like psql://user:pass@127.0.0.1:8458/db
DATABASES = {
# read os.environ['DATABASE_URL'] and raises
# ImproperlyConfigured exception if not found
"default": env.db(),
}


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

Expand Down
11 changes: 0 additions & 11 deletions app/storeroom/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,3 @@
SECRET_KEY = "change_me"

ALLOWED_HOSTS = ["*"]

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "devdb",
"USER": "postgres",
"PASSWORD": "change_me",
"HOST": "db",
"PORT": "5432",
}
}
10 changes: 0 additions & 10 deletions app/storeroom/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@
SECRET_KEY = env("SECRET_KEY")

ALLOWED_HOSTS = env("ALLOWED_HOSTS")

# Parse database connection url strings
# like psql://user:pass@127.0.0.1:8458/db
DATABASES = {
# read os.environ['DATABASE_URL'] and raises
# ImproperlyConfigured exception if not found
#
# The db() method is an alias for db_url().
"default": env.db(),
}

0 comments on commit a2e10c2

Please sign in to comment.