pkmntrade.club/scripts/reset-db_make-migrations_seed-data.sh

19 lines
599 B
Bash
Executable file

#!/bin/bash
# Exit immediately if any command exits with a non-zero status.
set -e
# Reset the database and migrations.
echo "Resetting database and migrations... "
docker compose down \
&& docker volume prune -a --filter label=db_is_resettable_via_script \
&& find . -path "*/migrations/00*.py" -delete \
&& docker compose up -d
# Wait for the database to be ready.
echo "Waiting for the database to be ready..."
sleep 10
echo "Loading seed data..."
docker compose exec -it web env DJANGO_SETTINGS_MODULE=django_project.settings django-admin loaddata /code/seed/0*
echo "Done & Started!"