You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from sqlalchemy import JSON, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from admin_app.db.models.base import AdminTimestampedModel
|
|
|
|
|
|
class AuditLog(AdminTimestampedModel):
|
|
__tablename__ = "admin_audit_logs"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
actor_staff_account_id: Mapped[int | None] = mapped_column(
|
|
Integer,
|
|
ForeignKey("staff_accounts.id"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
event_type: Mapped[str] = mapped_column(String(80), nullable=False, index=True)
|
|
resource_type: Mapped[str] = mapped_column(String(80), nullable=False, index=True)
|
|
resource_id: Mapped[str | None] = mapped_column(String(120), nullable=True, index=True)
|
|
outcome: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
|
|
message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
payload_json: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
ip_address: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
user_agent: Mapped[str | None] = mapped_column(String(512), nullable=True)
|