pkmntrade.club/scripts/reset-db_make-migrations_seed-data.sh
badbl0cks 51de3c7a6d
feat(dev): Enable hot reloading and streamline local development
This commit significantly improves the local development experience by enabling hot reloading for the Django application. This is achieved by installing the project as an editable package within the Docker services.

Key changes:

- **Hot Reloading:**
    - Modified `docker-compose.yml` for `web` and `celery` services to use `uv pip install --editable . --no-deps`.
    - Mounted the project root (`./`) to `/code` in `web` and `celery` services to facilitate the editable install.
- **Docker & Build Enhancements:**
    - Added `uv` binary to stage-1 in the `Dockerfile` for faster package operations.
    - Adjusted file permissions in `Dockerfile` during the app copy.
    - Set `DEBUG=true` for the `web` service in `docker-compose.yml` for easier local debugging.
    - Changed `restart` policy to `unless-stopped` for `web` and `celery` dev services.
    - Added a healthcheck for the `redis` service in the dev `docker-compose.yml`.
- **Code & Script Cleanup:**
    - Removed the custom `HealthCheckView` from the `home` app, as health checks are now handled by django-health-checks.
    - Updated paths and commands in `scripts/entrypoint.sh`, `scripts/prebuild.sh`, and `scripts/reset-db_make-migrations_seed-data.sh` to align with the new setup and remove obsolete steps (e.g., db cache table creation; we now use redis).
2025-05-23 21:19:33 -07:00

25 lines
608 B
Bash
Executable file

#!/bin/bash
# Exit immediately if any command exits with a non-zero status.
set -e
echo "Remaking migrations..."
find . -path "*/migrations/0*.py" -delete
set -a
source .env
set +a
uv run manage.py makemigrations --noinput
echo "Resetting dev database... "
docker compose down \
&& docker volume rm -f pkmntradeclub_postgres_data \
&& ./scripts/rebuild-and-run.sh
# Wait for the database to be ready.
echo "Waiting 15 seconds for migrations to be auto-run..."
sleep 15
echo "Loading seed data..."
docker compose exec -it web bash -c "django-admin loaddata /seed/0*"
docker compose down
echo "Done!"