Files
dpb/backend/app/api/v1/module_bre/pedigree/model.py
T
34047007@qq.com b95053c52c init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
2026-08-06 00:17:49 +08:00

41 lines
1.5 KiB
Python

"""系谱管理 数据模型"""
from datetime import datetime
from sqlalchemy import Float, ForeignKey, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import MappedBase, ModelMixin, UserMixin
class PedigreeModel(ModelMixin, UserMixin, MappedBase):
"""系谱管理 主数据表。"""
__tablename__ = "bre_pedigree"
combination_id: Mapped[int] = mapped_column(
Integer, ForeignKey("bre_cross_combination.id", ondelete="CASCADE"),
index=True, nullable=False, comment="来源杂交组合"
)
child_code: Mapped[str] = mapped_column(String(64), nullable=False, comment="子代种质编号")
dam_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_germplasm.id", ondelete="SET NULL"),
index=True, nullable=True, comment="母本(种质)"
)
sire_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_germplasm.id", ondelete="SET NULL"),
index=True, nullable=True, comment="父本(种质)"
)
generation: Mapped[str | None] = mapped_column(String(16), nullable=True, comment="世代", default=None)
remark: Mapped[str | None] = mapped_column(Text, nullable=True, comment="备注", default=None)
# 无 status 列:覆盖基类默认 ix_<表>_status_deleted 索引,
# 仅保留 (created_time, is_deleted) 复合索引用于数据权限过滤。
__table_args__ = (
Index("ix_bre_pedigree_created_deleted", "created_time", "is_deleted"),
)