-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·34 lines (28 loc) · 886 Bytes
/
setup.sh
File metadata and controls
executable file
·34 lines (28 loc) · 886 Bytes
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
#!/bin/bash
set -e
# Set project location
project_loc="$1"
# Source environment variables
source "$project_loc"/config/.env || {
echo "Error: Unable to load environment variables from config.env"
exit 1
}
# Change directory to project path
cd "$PROJECT_PATH"
# Apply migrations if necessary
if python3.9 manage.py showmigrations --plan | grep -q "\[ \]"; then
echo "Pending migrations found. Applying migrations..."
python3.9 manage.py migrate
echo "Migrations applied successfully."
else
echo "No pending migrations found."
fi
# Check for pending migrations
if python3.9 manage.py makemigrations myapp --check | grep -q "No changes detected"; then
echo "No pending migrations found."
else
# python3.9 manage.py flush --no-input
python3.9 manage.py makemigrations myapp
python3.9 manage.py migrate
echo "Migration done for myapp"
fi