#!/usr/bin/env python3
"""Recreate all tables from models (fresh start)."""

import sys
import os

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

from backend.db.models import Base
from backend.db.session import engine, get_database_url


def recreate_tables():
    """Recreate all tables from models."""
    db_url = get_database_url()
    print(f"Connecting to database: {db_url}")
    
    # Create all tables from models
    print("\nCreating all tables from models...")
    Base.metadata.create_all(bind=engine)
    
    print("✅ All tables created successfully!")
    print("✅ Database is now fresh and ready to use!")


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

