import asyncio import os import sys from sqlalchemy import text # Add project root to path sys.path.append(os.getcwd()) from core.database import engine async def check_tables(): print(f"Connecting to: {engine.url.render_as_string(hide_password=True)}") async with engine.connect() as conn: res = await conn.execute(text("SELECT table_name FROM information_schema.tables WHERE table_schema='public'")) tables = [r[0] for r in res.fetchall()] print("\n--- TABLES IN PUBLIC SCHEMA ---") for t in tables: print(f"- {t}") # Check for alembic_version specifically if "alembic_version" in tables: ver = await conn.execute(text("SELECT version_num FROM alembic_version")) print(f"\nALEMBIC CURRENT VERSION: {ver.scalar()}") else: print("\n❌ alembic_version TABLE MISSING") if __name__ == "__main__": asyncio.run(check_tables())