24 lines
894 B
Python
24 lines
894 B
Python
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, JSON, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class AuditLog(Base):
|
|
__tablename__ = "audit_logs"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
|
actor_id: Mapped[int] = mapped_column(ForeignKey("users.id"), index=True)
|
|
actor_source: Mapped[str] = mapped_column(String(32), default="web")
|
|
target_type: Mapped[str] = mapped_column(String(32))
|
|
target_id: Mapped[str] = mapped_column(String(128))
|
|
action: Mapped[str] = mapped_column(String(64))
|
|
result: Mapped[str] = mapped_column(String(32))
|
|
details: Mapped[dict] = mapped_column(JSON, default=dict)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
default=lambda: datetime.now(timezone.utc),
|
|
)
|