demand_belong_pool_rel.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from __future__ import annotations
  2. from datetime import datetime
  3. from sqlalchemy import BigInteger, Index, UniqueConstraint, func
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from supply_infra.db.base import Base
  6. class DemandBelongPoolRel(Base):
  7. """需求归属词与需求池行的匹配关系。"""
  8. __tablename__ = "demand_belong_pool_rel"
  9. __table_args__ = (
  10. UniqueConstraint(
  11. "demand_belong_category_id",
  12. "multi_demand_pool_di_id",
  13. name="uk_belong_pool",
  14. ),
  15. Index("idx_belong_category_id", "demand_belong_category_id"),
  16. Index("idx_pool_di_id", "multi_demand_pool_di_id"),
  17. )
  18. id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
  19. demand_belong_category_id: Mapped[int] = mapped_column(
  20. BigInteger, nullable=False, comment="demand_belong_category.id"
  21. )
  22. multi_demand_pool_di_id: Mapped[int] = mapped_column(
  23. BigInteger, nullable=False, comment="multi_demand_pool_di.id"
  24. )
  25. create_time: Mapped[datetime] = mapped_column(
  26. nullable=False,
  27. server_default=func.now(),
  28. comment="创建时间",
  29. )
  30. update_time: Mapped[datetime] = mapped_column(
  31. nullable=False,
  32. server_default=func.now(),
  33. onupdate=func.now(),
  34. comment="更新时间",
  35. )