"""Session model — one chat session = one idea discussion.""" 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 Session(SQLBase, UUIDMixin, TimestampMixin): __tablename__ = "sessions" user_id: Mapped[UUID] = mapped_column( UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True, ) title: Mapped[str] = mapped_column( String(255), nullable=False, default="Новое обсуждение" ) status: Mapped[str] = mapped_column( String(20), nullable=False, default="active", index=True ) idea_id: Mapped[Optional[UUID]] = mapped_column( UUID(as_uuid=True), ForeignKey("ideas.id", ondelete="SET NULL"), nullable=True, )