40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""AI PMO 回执账本。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Optional
|
|
|
|
from sqlalchemy import BigInteger, ForeignKey, Integer, UniqueConstraint, VARCHAR
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
from .types import JSONB
|
|
|
|
|
|
class ReplyReceipt(Base):
|
|
__tablename__ = "reply_receipts"
|
|
__table_args__ = (
|
|
UniqueConstraint(
|
|
"tenant_id",
|
|
"source_system",
|
|
"source_message_id",
|
|
"receipt_phase",
|
|
name="uq_reply_receipts_source_phase",
|
|
),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
work_item_id: Mapped[Optional[int]] = mapped_column(
|
|
BigInteger,
|
|
ForeignKey("work_items.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
source_system: Mapped[str] = mapped_column(VARCHAR(32), nullable=False, index=True)
|
|
source_message_id: Mapped[str] = mapped_column(VARCHAR(128), nullable=False, index=True)
|
|
receipt_phase: Mapped[str] = mapped_column(VARCHAR(32), nullable=False, index=True)
|
|
template_key: Mapped[Optional[str]] = mapped_column(VARCHAR(64), nullable=True)
|
|
payload: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|
|
status: Mapped[str] = mapped_column(VARCHAR(20), nullable=False, default="pending", index=True)
|
|
|