Mechanic's work place
Some checks failed
ci / test (push) Has been cancelled

This commit is contained in:
VPN SaaS Dev
2026-05-16 10:04:56 +09:00
parent fec9635079
commit 83ad880b9d
39 changed files with 2951 additions and 74 deletions

View File

@@ -0,0 +1,30 @@
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())