From d8798e508de4baf33d29d04f14270be9cc098f4d Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 10 Oct 2024 16:18:27 +0200 Subject: [PATCH] feat: added first logentry draft --- app/models/entry.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/models/entry.py b/app/models/entry.py index e69de29..19eeb64 100644 --- a/app/models/entry.py +++ b/app/models/entry.py @@ -0,0 +1,33 @@ +from creyPY.fastapi.models.base import Base +from sqlalchemy import Column, String, ForeignKey, Enum, JSON +from sqlalchemy.dialects.postgresql import UUID + +from enum import Enum as pyenum + + +class TransactionType(pyenum): + CREATE = "create" + UPDATE = "update" + DELETE = "delete" + UNDEFINED = "undefined" + + +class LogType(pyenum): + INFO = "info" + WARNING = "warning" + ERROR = "error" + CRITICAL = "critical" + + +class LogEntry(Base): + application = Column( + UUID(as_uuid=True), ForeignKey("application.id", ondelete="CASCADE"), nullable=False + ) + + t_type = Column(Enum(TransactionType), nullable=False, default=TransactionType.UNDEFINED) + l_type = Column(Enum(LogType), nullable=False, default=LogType.INFO) + + message = Column(String(512), nullable=True) + author = Column(String(512), nullable=False, default="system") + + previous_object = Column(JSON, nullable=True)