#!/usr/bin/env python3
"""Drop all tables from the web database to start fresh."""

import sys
import os

# Add project root to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from sqlalchemy import inspect
from src.web.db.session import engine, get_database_url
from src.web.db.models import Base


def drop_all_tables():
    """Drop all tables from the database."""
    db_url = get_database_url()
    print(f"Connecting to database: {db_url}")
    
    # Drop all tables
    print("\nDropping all tables...")
    Base.metadata.drop_all(bind=engine)
    
    print("✅ All tables dropped successfully!")
    print("\nYou can now recreate tables using:")
    print("  python scripts/recreate_tables_web.py")


if __name__ == "__main__":
    try:
        drop_all_tables()
    except Exception as e:
        print(f"❌ Error dropping tables: {e}")
        import traceback
        traceback.print_exc()
        sys.exit(1)

