#!/bin/bash
# Fix ghost migration on production server
# Run this INSIDE the api container or on the server

echo "=== Checking for ghost migration file ==="
find /app/alembic/versions -name "*tool_definition*" 2>/dev/null

echo ""
echo "=== Current alembic_version in DB ==="
psql "$DATABASE_URL" -c "SELECT * FROM alembic_version;"

echo ""
echo "=== Checking if tool_types has definition_manifests column ==="
psql "$DATABASE_URL" -c "\d tool_types" | grep -i manifest

echo ""
echo "=== Our known migration heads ==="
grep -r "revision.*=" /app/alembic/versions/*.py | grep "2026_05_28"
