#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")/.."

echo "==> Running database migrations"

if docker compose ps --services --filter "status=running" | grep -qx "hermes"; then
  docker compose exec -T hermes uv run alembic upgrade head
else
  cd backend/hermes
  uv run alembic upgrade head
fi

echo "==> Migrations completed"
