Skip to content

Commit

Permalink
chore: change seeding method
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Apr 18, 2024
1 parent 545a280 commit 0149dd3
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,41 +75,44 @@ fi
# Seed database if data size is provided
if [ "$data" != "" ]; then
# Cleanup function
cleanup() {
echo "Ctrl+C detected. Cleaning up..."
deactivate
rm -rf .venv_dev
exit 1
}
# cleanup() {
# echo "Ctrl+C detected. Cleaning up..."
# deactivate
# rm -rf .venv_dev
# exit 1
# }

# Call cleanup function on SIGINT
trap cleanup SIGINT
# # Call cleanup function on SIGINT
# trap cleanup SIGINT

echo "--------------------------"
echo "Filling the database."
echo "This can take some time..."
echo "--------------------------"

cd backend
rm -f backend/db.sqlite3 > /dev/null 2>&1
docker run -v backend:/code ugent-7_backend sh -c "python manage.py migrate; python manage.py loaddata */fixtures/small/*" > /dev/null

# cd backend

rm -f db.sqlite3 > /dev/null 2>&1
# rm -f db.sqlite3 > /dev/null 2>&1

echo "Setting up workspace..."
python3 -m venv .venv_dev > /dev/null
source .venv_dev/bin/activate
pip install poetry > /dev/null
poetry install > /dev/null
# echo "Setting up workspace..."
# python3 -m venv .venv_dev > /dev/null
# source .venv_dev/bin/activate
# pip install poetry > /dev/null
# poetry install > /dev/null

echo "Migrating database..."
python manage.py migrate > /dev/null
# echo "Migrating database..."
# python manage.py migrate > /dev/null

echo "Filling $data database..."
python manage.py loaddata */fixtures/$data/* > /dev/null 2>&1
# echo "Filling $data database..."
# python manage.py loaddata */fixtures/$data/* > /dev/null 2>&1

echo "Resetting workspace..."
deactivate
rm -rf .venv_dev
cd ..
# echo "Resetting workspace..."
# deactivate
# rm -rf .venv_dev
# cd ..
fi

# Build Docker images
Expand Down

0 comments on commit 0149dd3

Please sign in to comment.