feat(platform): add audit logs and activity feed
This commit is contained in:
parent
92cb8d1286
commit
c816e9869d
34 changed files with 1592 additions and 43 deletions
28
backend/hermes/app/models/audit.py
Normal file
28
backend/hermes/app/models/audit.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, Integer, JSON, String, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.db.database import Base
|
||||
|
||||
|
||||
class AuditLog(Base):
|
||||
__tablename__ = "audit_logs"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
actor_user_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
actor_username: Mapped[str] = mapped_column(String(120), default="", server_default="")
|
||||
action: Mapped[str] = mapped_column(String(120), index=True)
|
||||
entity_type: Mapped[str] = mapped_column(String(80), index=True)
|
||||
entity_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
||||
entity_label: Mapped[str] = mapped_column(String(255), default="", server_default="")
|
||||
ip_address: Mapped[str] = mapped_column(String(80), default="", server_default="")
|
||||
user_agent: Mapped[str] = mapped_column(Text, default="", server_default="")
|
||||
before_data: Mapped[dict | list | None] = mapped_column(JSON, nullable=True)
|
||||
after_data: Mapped[dict | list | None] = mapped_column(JSON, nullable=True)
|
||||
metadata_data: Mapped[dict | list | None] = mapped_column("metadata", JSON, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
Loading…
Add table
Add a link
Reference in a new issue