1"""Officer/GM console action audit trail."""
2
3from advanced_alchemy.base import UUIDAuditBase
4from sqlalchemy import BigInteger, ForeignKey, String, Text
5from sqlalchemy.orm import Mapped, mapped_column
6
7
[docs]
8class OfficerAudit(UUIDAuditBase):
9 """One officer/GM-performed change, recorded in the same request as the change itself.
10
11 Bot/Discord-originated changes are never audited here (no officer/GM actor). ``actor_name`` is a snapshot of
12 the actor's display name at the time, so the row still reads sensibly after ``actor_member_id`` is nulled
13 (kept, not deleted) when the actor's account is later deleted.
14 """
15
16 __tablename__ = "officer_audit"
17 __table_args__ = {"comment": "Officer/GM console action audit trail."}
18
19 actor_member_id: Mapped[int | None] = mapped_column(
20 BigInteger, ForeignKey("member.id", ondelete="SET NULL"), index=True, default=None
21 )
22 actor_name: Mapped[str] = mapped_column(Text)
23 action: Mapped[str] = mapped_column(String(40))
24 subject_type: Mapped[str] = mapped_column(String(20))
25 subject_id: Mapped[str | None] = mapped_column(String(64), default=None)
26 summary: Mapped[str] = mapped_column(String(300))