-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_reset
executable file
·33 lines (25 loc) · 879 Bytes
/
db_reset
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# enter the dir and venv
cd $(dirname -- "$( readlink -f -- "$0"; )";);
source ./activate
echo "This will delete the database."
read -p "Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# clear db
#cfc_report/migrations/0001_initial.py
find cfc_report/migrations -type f -name '*.pyc' -delete
find cfc_report/migrations -type f -name "*.py" -not -name "__init__.py" -delete
rm "db.sqlite3"
echo "Django db and migrations cleared"
python manage.py makemigrations
# make the tables
python manage.py migrate
# run python to populate test data
echo "from cfc_report.services import database as db; db.populate_database();" | \
python manage.py shell
python manage.py makemigrations
python manage.py migrate
echo "database repopulated with dumbby data and migrated."
fi