-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.sh
34 lines (23 loc) · 1.15 KB
/
reset.sh
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
echo "Stopping all containers..."
docker compose down
echo "Creating external volumes if they don't exist..."
docker volume create --name=postgres_data || true
docker volume create --name=minio_data || true
docker volume create --name=qdrant_data || true
echo "Resetting data..."
docker compose -f docker-compose.reset.yml up --build
echo "Removing old containers and volumes..."
docker compose down -v
echo "Starting services with fresh data..."
docker compose up -d --remove-orphans
echo "Running database migrations..."
docker compose exec -e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB fastapi-app bash -c "cd /app && alembic upgrade head"
echo "Creating new migration if needed..."
docker compose exec -e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB fastapi-app bash -c "cd /app && alembic revision --autogenerate -m 'Auto-generated migration'" || true
echo "Applying any new migrations..."
docker compose exec -e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB fastapi-app bash -c "cd /app && alembic upgrade head"
echo "Shutting down containers"
docker compose down
echo "Reset complete. Your environment is now fresh and updated."