Skip to content

Commit

Permalink
Removing DATABASE_URL environment variable (#4096)
Browse files Browse the repository at this point in the history
* Removing DATABASE_URL environment variable

* Test unsetting env variable via scripts

* Unsetting env variable from scripts

* Testing a different approach

* Removed unnecessary code

* More cleaning

* More cleaning
  • Loading branch information
sambodeme authored Jul 22, 2024
1 parent 0e15946 commit 9e9d4b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/.profile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ if [[ "$CF_INSTANCE_INDEX" == 0 ]]; then
fi

# Make psql usable by scripts, for debugging, etc.
alias psql='/home/vcap/deps/0/apt/usr/lib/postgresql/*/bin/psql'
alias psql='/home/vcap/deps/0/apt/usr/lib/postgresql/*/bin/psql'
13 changes: 8 additions & 5 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
"default": env.dj_db_url(
"DATABASE_URL", default="postgres://postgres:[email protected]/backend"
),
}

POSTGREST = {
"URL": env.str("POSTGREST_URL", "http://api:3000"),
Expand Down Expand Up @@ -237,6 +232,13 @@
# Environment specific configurations
DEBUG = False
if ENVIRONMENT not in ["DEVELOPMENT", "PREVIEW", "STAGING", "PRODUCTION"]:

DATABASES = {
"default": env.dj_db_url(
"DATABASE_URL", default="postgres://postgres:[email protected]/backend"
),
}

# Local environment and Testing environment (CI/CD/GitHub Actions)

if ENVIRONMENT == "LOCAL":
Expand Down Expand Up @@ -284,6 +286,7 @@
# One of the Cloud.gov environments
STATICFILES_STORAGE = "storages.backends.s3boto3.S3ManifestStaticStorage"
DEFAULT_FILE_STORAGE = "report_submission.storages.S3PrivateStorage"

vcap = json.loads(env.str("VCAP_SERVICES"))

DB_URL = get_db_url_from_vcap_services(vcap)
Expand Down

0 comments on commit 9e9d4b3

Please sign in to comment.