#!/bin/bash
# Rebuild and restart the Workout Planner
# Usage: ./scripts/rebuild.sh

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_DIR"

echo "Stopping server..."
"$SCRIPT_DIR/stop.sh"

echo ""
echo "Applying database migrations..."
npx prisma db push

echo ""
echo "Building production bundle..."
npm run build

echo ""
echo "Starting server..."
"$SCRIPT_DIR/start.sh"
