from __future__ import annotations import asyncio from sqlalchemy import select from app.core.config import settings from app.db.session import async_session_factory from app.models.user import User async def main() -> None: admin_ids = settings.admin_telegram_id_list if not admin_ids: raise SystemExit("ADMIN_TELEGRAM_IDS is empty") async with async_session_factory() as session: for telegram_id in admin_ids: result = await session.execute(select(User).where(User.telegram_id == telegram_id)) user = result.scalar_one_or_none() if user is None: user = User(telegram_id=telegram_id, username=str(telegram_id), platform_role="admin") session.add(user) else: user.platform_role = "admin" await session.commit() print(f"Bootstrapped admins: {', '.join(str(item) for item in admin_ids)}") if __name__ == "__main__": asyncio.run(main())