Spaces:
Paused

File size: 899 Bytes
5eb4857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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={})