- db-backup sidecar: pg_dump -Fc of procurement+casdoor every BACKUP_INTERVAL_SECONDS into BACKUP_DIR, retention via BACKUP_KEEP_DAYS - audit_log table (migration.sql + runtime ensure_audit_table) with model + transactional helper (utils/audit.record) — wired into user create/role-change and inventory transaction creation - get_actor: quote_events.actor now stores the VERIFIED user's display name instead of the raw bearer token
20 lines
785 B
Python
20 lines
785 B
Python
"""Audit log model — general activity trail (v2.7)."""
|
|
import uuid
|
|
|
|
from sqlalchemy import Column, DateTime, String, Text, func
|
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class AuditLog(Base):
|
|
__tablename__ = "audit_log"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
occurred_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
actor = Column(Text, nullable=True) # display name of the authenticated user
|
|
action = Column(String(64), nullable=False) # e.g. "user.role_changed"
|
|
entity = Column(String(64), nullable=False) # e.g. "user", "inventory_tx"
|
|
entity_id = Column(Text, nullable=True)
|
|
details = Column(JSONB, nullable=False, server_default="{}")
|