PMFlow/backend/app/models/model_requirement_binding.py

37 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""模型与需求绑定"""
from datetime import datetime
from typing import Optional
from sqlalchemy import BigInteger, DECIMAL, ForeignKey, Integer, Text, TIMESTAMP, func
from sqlalchemy.orm import Mapped, mapped_column
from .base import BaseNoTenant
class BaseCreatedOnly(BaseNoTenant):
"""仅有 tenant_id 和 created_at,无 updated_at"""
__abstract__ = True
tenant_id: Mapped[int] = mapped_column(
BigInteger, nullable=False, default=1, index=True
)
created_at: Mapped[datetime] = mapped_column(
TIMESTAMP, nullable=False, server_default=func.now()
)
class ModelRequirementBinding(BaseCreatedOnly):
__tablename__ = "model_requirement_bindings"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
truth_node_id: Mapped[int] = mapped_column(
BigInteger, ForeignKey("truth_nodes.id"), nullable=False
)
model_version_id: Mapped[int] = mapped_column(
BigInteger, ForeignKey("model_versions.id"), nullable=False
)
estimated_cost: Mapped[Optional[float]] = mapped_column(
DECIMAL(10, 2), nullable=True
)
compatibility_score: Mapped[int] = mapped_column(Integer, nullable=False)
risk_notes: Mapped[Optional[str]] = mapped_column(Text, nullable=True)