"""QA 会话模型。""" from __future__ import annotations from typing import Optional from sqlalchemy import BigInteger, Integer, TIMESTAMP, VARCHAR from sqlalchemy.orm import Mapped, mapped_column from .base import Base class QASession(Base): __tablename__ = "qa_sessions" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) user_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True, index=True) title: Mapped[str] = mapped_column(VARCHAR(120), nullable=False, default="新会话") project_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True, index=True) started_at: Mapped[Optional[TIMESTAMP]] = mapped_column(TIMESTAMP, nullable=True, index=True) last_message_at: Mapped[Optional[TIMESTAMP]] = mapped_column(TIMESTAMP, nullable=True, index=True) message_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)