Files
MyClub/fix_admin_issues.sh
T
Tomas Dvorak dfc079288f hot fix #1
2026-01-26 08:13:18 +01:00

58 lines
2.2 KiB
Bash

#!/bin/bash
echo "=== Fixing Admin Issues ==="
# Step 1: Run database migrations
echo "Step 1: Running database migrations..."
cd /home/tdvorak/Desktop/PROG+HTML/Fotbal/fotbal-club
go run main.go migrate-up
# Step 2: Check if backend is running
echo "Step 2: Checking backend status..."
if curl -s http://localhost:8080/api/v1/health > /dev/null; then
echo "Backend is already running"
else
echo "Starting backend..."
# Start backend in background
go run main.go &
BACKEND_PID=$!
echo "Backend started with PID: $BACKEND_PID"
# Wait for backend to start
echo "Waiting for backend to start..."
for i in {1..30}; do
if curl -s http://localhost:8080/api/v1/health > /dev/null; then
echo "Backend is ready!"
break
fi
echo "Waiting... ($i/30)"
sleep 1
done
fi
# Step 3: Test the problematic endpoints
echo "Step 3: Testing endpoints..."
echo "Testing QR codes endpoint..."
curl -s -w "\nStatus: %{http_code}\n" http://localhost:8080/api/v1/admin/qr-codes || echo "QR codes endpoint failed"
echo "Testing expenses endpoint..."
curl -s -w "\nStatus: %{http_code}\n" "http://localhost:8080/api/v1/admin/financial/expenses?page=1&limit=20" || echo "Expenses endpoint failed"
echo "Testing expenses categories endpoint..."
curl -s -w "\nStatus: %{http_code}\n" http://localhost:8080/api/v1/admin/financial/expenses/categories || echo "Expenses categories endpoint failed"
echo "Testing invoices endpoint..."
curl -s -w "\nStatus: %{http_code}\n" http://localhost:8080/api/v1/admin/invoices || echo "Invoices endpoint failed"
echo "Testing customers endpoint..."
curl -s -w "\nStatus: %{http_code}\n" http://localhost:8080/api/v1/admin/invoices/customers || echo "Customers endpoint failed"
echo "Testing invoice settings endpoint..."
curl -s -w "\nStatus: %{http_code}\n" http://localhost:8080/api/v1/admin/invoices/settings || echo "Invoice settings endpoint failed"
echo "=== Fix Complete ==="
echo "If you see 404 errors, the routes might not be properly registered."
echo "If you see 500 errors, the database tables might not exist or there are database issues."
echo "Check the backend logs for more details."