Skip to content

Commit 58c9c68

Browse files
committed
feat(init): guard database delete with env var
DJANGO_DB_RESET is true by default to maintain existing behavior
1 parent 305bcd2 commit 58c9c68

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

bin/init.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env bash
22
set -eux
33

4-
# construct the path to the database file from environment or default
5-
6-
DB_DIR="${DJANGO_DB_DIR:-.}"
7-
DB_FILE="${DB_DIR}/django.db"
8-
94
# remove existing (old) database file
10-
# -f forces the delete (and avoids an error when the file doesn't exist)
115

12-
rm -f "${DB_FILE}"
6+
if [[ ${DJANGO_DB_RESET:-true} = true ]]; then
7+
# construct the path to the database file from environment or default
8+
DB_DIR="${DJANGO_DB_DIR:-.}"
9+
DB_FILE="${DB_DIR}/django.db"
10+
11+
# -f forces the delete (and avoids an error when the file doesn't exist)
12+
rm -f "${DB_FILE}"
13+
fi
1314

1415
# run database migrations
1516

0 commit comments

Comments
 (0)