"""Log entry model for VoIdea.""" from typing import Optional from sqlalchemy import ForeignKey, String, Text from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import Mapped, mapped_column from app.core.base import SQLBase, TimestampMixin, UUIDMixin class LogEntry(SQLBase, UUIDMixin, TimestampMixin): __tablename__ = "log_entries" level: Mapped[str] = mapped_column( String(20), nullable=False, index=True ) source: Mapped[str] = mapped_column( String(100), nullable=False, index=True ) message: Mapped[str] = mapped_column( Text, nullable=False ) details: Mapped[Optional[str]] = mapped_column( Text, nullable=True ) user_id: Mapped[Optional[UUID]] = mapped_column( UUID(as_uuid=True), ForeignKey("users.id", ondelete="SET NULL"), nullable=True, index=True, )