18 lines
808 B
Python
18 lines
808 B
Python
from sqlalchemy import Column, String, DateTime, ForeignKey, JSON
|
|
from sqlalchemy.sql import func
|
|
from app.core.database.db_session import Base
|
|
|
|
class AuditLog(Base):
|
|
__tablename__ = "audit_logs"
|
|
|
|
audit_id = Column(String(26), primary_key=True)
|
|
request_id = Column(String(50), nullable=False)
|
|
user_id = Column(String(26), ForeignKey("users.user_id", ondelete="SET NULL"), nullable=True)
|
|
entity_type = Column(String(50), nullable=False)
|
|
entity_id = Column(String(50), nullable=False)
|
|
action = Column(String(30), nullable=False)
|
|
old_value = Column(JSON, nullable=True)
|
|
new_value = Column(JSON, nullable=True)
|
|
ip_address = Column(String(45), nullable=False)
|
|
user_agent = Column(String(255), nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|