import psycopg2
import os

def get_db_connection():
    """Create a database connection"""
    try:
        conn = psycopg2.connect(
            host="localhost",
            database="bookbeach",
            user="postgres",
            password="F@f@k0s!!"
        )
        return conn
    except Exception as e:
        print(f"Error connecting to database: {e}")
        return None

def check_restaurant_items_columns(conn):
    """Check the columns in the restaurant_items table"""
    try:
        cursor = conn.cursor()
        cursor.execute("""
            SELECT column_name, data_type 
            FROM information_schema.columns 
            WHERE table_name = 'restaurant_items' 
            ORDER BY ordinal_position
        """)
        
        columns = cursor.fetchall()
        print("Restaurant items table columns:")
        for column in columns:
            print(f"  {column[0]} ({column[1]})")
        
        cursor.close()
        return columns
    except Exception as e:
        print(f"Error checking restaurant_items table: {e}")
        return []

def main():
    print("Checking current state of restaurant_items table...")
    
    # Get database connection
    conn = get_db_connection()
    if not conn:
        print("Failed to connect to database")
        return
    
    try:
        check_restaurant_items_columns(conn)
    except Exception as e:
        print(f"Error during check: {e}")
        import traceback
        traceback.print_exc()
    finally:
        if conn:
            conn.close()

if __name__ == "__main__":
    main()