diff --git a/scripts/deploy/scripts/run_migrations.sh b/scripts/deploy/scripts/run_migrations.sh index 94abb56d..d1c4215f 100755 --- a/scripts/deploy/scripts/run_migrations.sh +++ b/scripts/deploy/scripts/run_migrations.sh @@ -32,20 +32,13 @@ ssh $SERVER \ cd /home/cmc/$WORK_DIR echo "Running migrations in $WORK_DIR..." - # Wait for Go service to be ready - echo "Waiting for Go service to be ready..." - for i in {1..30}; do - if docker compose $ENV_FILE -f "$COMPOSE_FILE" exec -T "$GO_SERVICE" test -f /app/go.mod 2>/dev/null; then - echo "Go service is ready." - break - fi - if [ $i -eq 30 ]; then - echo "ERROR: Go service is not running or not ready." - exit 1 - fi - sleep 2 - done + # Check if Go service is running + if ! docker ps --filter "name=$GO_SERVICE" --filter "status=running" --format "{{.Names}}" | grep -q "$GO_SERVICE"; then + echo "ERROR: Go service ($GO_SERVICE) is not running." + exit 1 + fi + echo "Go service is running. Executing migrations..." docker compose $ENV_FILE -f "$COMPOSE_FILE" exec -T "$GO_SERVICE" sh -c "cd /app && make migrate" echo "Migrations completed successfully." ENDSSH