from sqlalchemy import Integer, String, Text from sqlalchemy.dialects.sqlite import JSON from sqlalchemy.orm import Mapped, mapped_column from core_db import AuditMixin, Base, TenantMixin, VersionMixin class Message(TenantMixin, AuditMixin, VersionMixin, Base): __tablename__ = "message" session_id: Mapped[str] = mapped_column(String(36), index=True) turn_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True) role: Mapped[str] = mapped_column(String(32)) content_type: Mapped[str] = mapped_column(String(32)) content_text: Mapped[str | None] = mapped_column(Text, nullable=True) content_json: Mapped[dict | None] = mapped_column(JSON, nullable=True) token_count: Mapped[int | None] = mapped_column(Integer, nullable=True)