from app.core.database import engine
from sqlalchemy import text, inspect

def migrate():
    with engine.connect() as conn:
        inspector = inspect(engine)
        columns = [c['name'] for c in inspector.get_columns('taxis')]
        
        if 'rating' not in columns:
            print("Adding column rating...")
            conn.execute(text("ALTER TABLE taxis ADD COLUMN rating FLOAT DEFAULT 5.0"))
        
        if 'english_speaking' not in columns:
            print("Adding column english_speaking...")
            conn.execute(text("ALTER TABLE taxis ADD COLUMN english_speaking BOOLEAN DEFAULT FALSE"))
            
        if 'image_url' not in columns:
            print("Adding column image_url...")
            conn.execute(text("ALTER TABLE taxis ADD COLUMN image_url VARCHAR"))
            
        conn.commit()
        print("Migration completed!")

if __name__ == "__main__":
    migrate()
