from sqlalchemy import Boolean, ForeignKey, String, Text, UniqueConstraint, Index from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base, TimestampMixin class ContactRequest(Base, TimestampMixin): __tablename__ = "contact_requests" id: Mapped[str] = mapped_column(String(32), primary_key=True) user_id: Mapped[str] = mapped_column(String(32), ForeignKey("users.id"), index=True) phone: Mapped[str] = mapped_column(String(20), index=True) company_name: Mapped[str] = mapped_column(String(128)) industry: Mapped[str] = mapped_column(String(64)) name: Mapped[str] = mapped_column(String(64)) message: Mapped[str | None] = mapped_column(Text, nullable=True) is_handled: Mapped[bool] = mapped_column(Boolean, default=False) submit_date: Mapped[str] = mapped_column(String(10), index=True) __table_args__ = ( UniqueConstraint('user_id', 'submit_date', name='uq_contact_user_date'), Index('idx_contact_handled_created', 'is_handled', 'created_at'), Index('idx_contact_user_date_created', 'user_id', 'submit_date', 'created_at'), )