from app.database import SessionLocal
from sqlalchemy import text

db = SessionLocal()
try:
    # Set all roles to false
    db.execute(text("UPDATE roles SET is_default = false"))
    db.commit()
    
    # Set viewer to true
    db.execute(text("UPDATE roles SET is_default = true WHERE name = 'viewer'"))
    db.commit()
    
    print("Boolean values corrected - viewer is now default role")
except Exception as e:
    print(f"Error: {e}")
    db.rollback()
finally:
    db.close()
