Первоначальная версия VidConf

This commit is contained in:
2026-07-23 01:04:01 +03:00
commit 896455381a
335 changed files with 61527 additions and 0 deletions

51
backend/scripts/seed.py Normal file
View File

@@ -0,0 +1,51 @@
"""Идемпотентный seed скрипт: единственный админ-пользователь.
Комнаты (100 демо-комнат) больше не существуют как сущность (ADR-001) —
seed сокращён до создания администратора.
Запустить с: `uv run python -m scripts.seed`
"""
import asyncio
from argon2 import PasswordHasher
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from core.config import get_settings
from core.db import async_session_maker, engine
from models.user import User
_hasher = PasswordHasher()
async def _seed_admin(session: AsyncSession) -> None:
settings = get_settings()
email = settings.seed_admin_email
password = settings.seed_admin_password
existing = await session.scalar(select(User).where(User.email == email))
if existing is not None:
return
session.add(
User(
email=email,
name_user="Admin",
password_hash=_hasher.hash(password),
role="admin",
email_verified=True,
)
)
async def seed() -> None:
"""Upsert админ-пользователя; безопасно запускать несколько раз."""
async with async_session_maker() as session:
await _seed_admin(session)
await session.commit()
await engine.dispose()
if __name__ == "__main__":
asyncio.run(seed())