Skip to content

Commit

Permalink
feat: add script for resetting the database
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Feb 8, 2024
1 parent 455df46 commit c402704
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bin/reset_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eux

# remove database file

# construct the path to the database file from environment or default
DB_DIR="${DJANGO_DB_DIR:-.}"
DB_FILE="${DB_DIR}/django.db"

# -f forces the delete (and avoids an error when the file doesn't exist)
rm -f "${DB_FILE}"

# run database migrations

python manage.py migrate

# create a superuser account for backend admin access
# (set username, email, and password using environment variables
# DJANGO_SUPERUSER_USERNAME, DJANGO_SUPERUSER_EMAIL, and DJANGO_SUPERUSER_PASSWORD)

python manage.py createsuperuser --no-input
12 changes: 12 additions & 0 deletions docs/configuration/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ By default the application sends logs to `stdout`.

Django's primary secret, keep this safe!

### `DJANGO_SUPERUSER_EMAIL`

The email address of the Django Admin superuser created when resetting the database.

### `DJANGO_SUPERUSER_PASSWORD`

The password of the Django Admin superuser created when resetting the database.

### `DJANGO_SUPERUSER_USERNAME`

The username of the Django Admin superuser created when resetting the database.

### `DJANGO_TRUSTED_ORIGINS`

!!! warning "Deployment configuration"
Expand Down

0 comments on commit c402704

Please sign in to comment.