from __future__ import annotations from datetime import datetime from sqlalchemy import BigInteger, Index, UniqueConstraint, func from sqlalchemy.orm import Mapped, mapped_column from supply_infra.db.base import Base class DemandBelongPoolRel(Base): """需求归属词与需求池行的匹配关系。""" __tablename__ = "demand_belong_pool_rel" __table_args__ = ( UniqueConstraint( "demand_belong_category_id", "multi_demand_pool_di_id", name="uk_belong_pool", ), Index("idx_belong_category_id", "demand_belong_category_id"), Index("idx_pool_di_id", "multi_demand_pool_di_id"), ) id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) demand_belong_category_id: Mapped[int] = mapped_column( BigInteger, nullable=False, comment="demand_belong_category.id" ) multi_demand_pool_di_id: Mapped[int] = mapped_column( BigInteger, nullable=False, comment="multi_demand_pool_di.id" ) create_time: Mapped[datetime] = mapped_column( nullable=False, server_default=func.now(), comment="创建时间", ) update_time: Mapped[datetime] = mapped_column( nullable=False, server_default=func.now(), onupdate=func.now(), comment="更新时间", )