Spaces:
Paused

nexus / models /audit_log.py
dushyantsingh0
Beta 1.0: Pure Backend Release (Excluding Frontend)
5eb4857
Raw History Blame Contribute Delete
899 Bytes
from sqlalchemy import Column, String, ForeignKey, JSON, DateTime
from sqlalchemy.dialects.postgresql import UUID, JSONB
from core.database import Base
from models.base import PrimaryKeyMixin, TimestampMixin
class AuditLog(Base, PrimaryKeyMixin, TimestampMixin):
__tablename__ = "audit_logs"
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), nullable=False, index=True)
entity_type = Column(String(50), nullable=False, index=True) # e.g., "ticket"
entity_id = Column(UUID(as_uuid=True), nullable=False, index=True)
action = Column(String(100), nullable=False) # e.g., "status_change", "reassignment"
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True) # NULL if system/AI
old_value = Column(JSONB, nullable=True)
new_value = Column(JSONB, nullable=True)
metadata_json = Column(JSONB, nullable=True, default={})