Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: parameterize Django database path/deletion #1770

Merged
merged 6 commits into from Nov 2, 2023
Merged

Conversation

thekaveman
Copy link
Member

@thekaveman thekaveman commented Nov 1, 2023

Closes #1763

Testing / review

In your local .env file, try different values for the environment variables.

Note the DJANGO_DB_DIR must already exist!

E.g. to create the database file in a local (to your repo) directory called db:

# make sure the directory exists!
mkdir db

Then set the environment variable and reload your devcontainer:

DJANGO_DB_DIR=./db

Verify bin/init.sh output:

$ DJANGO_DB_DIR=./db bin/init.sh 
+ [[ true = true ]]
+ DB_DIR=./db
+ DB_FILE=./db/django.db
+ rm -f ./db/django.db
+ python manage.py migrate
Operations to perform:
  Apply all migrations: core, sessions
Running migrations:
  Applying core.0001_initial... OK
  Applying core.0002_data... OK
  Applying sessions.0001_initial... OK

Set DJANGO_DB_RESET to false to keep the database between restarts/reinits:

DJANGO_DB_RESET=false

Verify bin/init.sh output:

$ DJANGO_DB_RESET=false bin/init.sh 
+ [[ false = true ]]
+ python manage.py migrate
Operations to perform:
  Apply all migrations: core, sessions
Running migrations:
  No migrations to apply.

Before merge

  • Create django-db-dir secret in Key Vault (x3), set to /home/site/wwwroot
  • Create django-db-reset secret in Key Vault (x3), set to true

After merge

You shouldn't have to make any changes to your local setup, unless you want to per the above settings.

@github-actions github-actions bot added the back-end Django views, sessions, middleware, models, migrations etc. label Nov 1, 2023
Copy link

github-actions bot commented Nov 1, 2023

Coverage report

The coverage rate went from 90.9% to 90.91% ⬆️
The branch rate is 85%.

100% of new lines are covered.

Diff Coverage details (click to unfold)

benefits/settings.py

100% of new lines are covered (83.58% of the complete file).

@thekaveman thekaveman added the documentation [auto] Improvements or additions to documentation label Nov 1, 2023
set via the DJANGO_DB_DIR environment variable

default to the current directory '.'
remove reference to a Docker env var that is no longer used
DJANGO_DB_RESET is true by default to maintain existing behavior
Base automatically changed from chore/devcontainer to dev November 1, 2023 23:12
@thekaveman thekaveman linked an issue Nov 1, 2023 that may be closed by this pull request
5 tasks
@thekaveman thekaveman self-assigned this Nov 1, 2023
@thekaveman thekaveman marked this pull request as ready for review November 1, 2023 23:29
@thekaveman thekaveman requested a review from a team as a code owner November 1, 2023 23:29
Copy link
Member

@angela-tran angela-tran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me

@thekaveman thekaveman changed the title Feat: parameterize Django database Feat: parameterize Django database path/deletion Nov 2, 2023
@thekaveman thekaveman merged commit fcf009b into dev Nov 2, 2023
11 checks passed
@thekaveman thekaveman deleted the feat/db-params branch November 2, 2023 22:06
@thekaveman thekaveman added this to the Admin tool: v1 milestone Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. documentation [auto] Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameterize database path and deletion
2 participants