from sqlalchemy.ext.asyncio import AsyncSession
from app.models.models import AuditLog


async def write_audit_log(db: AsyncSession, action: str, user_id: int | None, payload: dict | None = None) -> None:
    db.add(AuditLog(action=action, user_id=user_id, payload=payload or {}))
    await db.commit()
