From c55bc55138e08884dcbb15ca8d856b583e883891 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Wed, 20 May 2026 05:19:20 +0800 Subject: [PATCH] fix(models): remove relationship declarations that require ForeignKey constraints The project does not use SQLAlchemy ORM-level relationships or ForeignKey constraints. All joins are done manually in CRUD queries. The relationship() declarations on BizProductionWorkOrder.tasks and BizProductionTask.steps caused mapper initialization failures because the child table columns lack ForeignKey definitions. --- backend/app/models/models.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/app/models/models.py b/backend/app/models/models.py index d9fb5c1cb..e9f96663d 100644 --- a/backend/app/models/models.py +++ b/backend/app/models/models.py @@ -3,7 +3,6 @@ from datetime import datetime import enum from sqlalchemy import Column, String, DateTime, Integer, Text, CHAR, SmallInteger, Numeric -from sqlalchemy.orm import relationship from app.core.database import Base @@ -2174,7 +2173,6 @@ class BizProductionWorkOrder(Base): update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间") del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记") - tasks = relationship("BizProductionTask", backref="work_order", lazy="dynamic") class BizProductionTask(Base): @@ -2202,7 +2200,6 @@ class BizProductionTask(Base): update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间") del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记") - steps = relationship("BizProductionTaskStep", backref="task", lazy="dynamic") class BizProductionTaskInput(Base):