-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload_fixtures.sh
More file actions
executable file
·54 lines (47 loc) · 1.21 KB
/
load_fixtures.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.21 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
db_host=$(python manage.py diffsettings | grep DB_HOST | awk '{print $3}')
if [[ "$db_host" != "'localhost'" ]]; then
echo "This script is only available in localhost as DB_HOST."
exit
fi
declare -a fixtures_things=(
)
declare -a fixtures_accounts=(
)
declare -a fixtures_test=(
"accounts_test.json"
)
declare -a fixtures=()
if [ $# -eq 0 ]; then
declare -a fixtures=(
"${fixtures_things[@]}"
"${fixtures_accounts[@]}"
)
else
for argval in "$@"
do
if [ "$argval" == "things" ]; then
fixtures+=("${fixtures_things[@]}")
fi
if [ "$argval" == "accounts" ]; then
fixtures+=("${fixtures_accounts[@]}")
fi
if [ "$argval" == "test" ]; then
fixtures+=("${fixtures_test[@]}")
fi
done
fi
echo "# loading following fixtures: ${fixtures[@]}"
for fixture in "${fixtures[@]}"
do
echo " $fixture..."
SECONDS=0
python manage.py loaddata "$fixture" --settings=bbgo.migration_settings
duration=$SECONDS
if [ $? -eq 0 ]; then
echo "# successfully loaded" "$fixture" "in $duration seconds."
else
echo "# error while loading" "$fixture"
break
fi
done