"""One-time script to promote a user to admin. Run on the server where .env has the correct MONGODB_URI. Usage: python promote_admin.py nick.viljoen@brandtech.plus """ import asyncio import sys from dotenv import load_dotenv load_dotenv() from database import users_collection async def promote(email: str): user = await users_collection.find_one({"email": email}) if not user: print(f"User '{email}' not found in database.") return if user.get("is_admin"): print(f"User '{email}' is already an admin.") return await users_collection.update_one( {"email": email}, {"$set": {"is_admin": True}}, ) print(f"User '{email}' promoted to admin successfully.") if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python promote_admin.py ") sys.exit(1) asyncio.run(promote(sys.argv[1]))