Files
bacchus/apps/backend/app/models/audit_log.py
2025-09-28 19:13:01 +02:00

30 lines
988 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from app.core.database import Base
from sqlalchemy import Column, Integer, String, DateTime, Enum, ForeignKey
from sqlalchemy.orm import relationship
from datetime import datetime
import enum
class AuditAction(enum.Enum):
booking_create = "booking_create"
booking_delete = "booking_delete"
topup_create = "topup_create"
# Weitere Aktionen können hier ergänzt werden, z.B.:
# topup_confirm = "topup_confirm"
# user_update = "user_update"
class AuditLog(Base):
__tablename__ = "audit_logs"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
action = Column(String, nullable=False)
amount_cents = Column(Integer, nullable=True)
old_balance_cents = Column(Integer, nullable=True)
new_balance_cents = Column(Integer, nullable=True)
info = Column(String, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
user = relationship("User")