"""Erstellt beim ersten Start einen Admin-Benutzer, falls noch keiner existiert.""" from sqlalchemy.orm import Session from .config import get_settings from .models import Role, User from .security import hash_password def ensure_first_admin(db: Session) -> None: settings = get_settings() has_users = db.query(User).first() is not None if has_users: return admin = User( username=settings.admin_username, password_hash=hash_password(settings.admin_password), role=Role.admin, ) db.add(admin) db.commit()