from sqlalchemy import (UUID, Column, DateTime, Float, ForeignKey, Integer, String) from sqlalchemy.orm import relationship from src.database.core import Base from src.models import DefaultMixin, IdentityMixin, TimeStampMixin class EquipmentWorkscopeGroup(Base, DefaultMixin): __tablename__ = "oh_tr_equipment_workscope_group" # overhaul_activity_id = Column( # UUID(as_uuid=True), ForeignKey("oh_tr_overhaul_activity.id"), nullable=False # ) # scope_equipment_job_id = Column( # UUID(as_uuid=True), # ForeignKey("oh_ms_scope_equipment_job.id", ondelete="cascade"), # nullable=False, # ) # notes = Column(String, nullable=True) # status = Column(String, nullable=True, default="pending") workscope_group_id = Column( UUID(as_uuid=True), ForeignKey("oh_ms_workscope_group.id"), nullable=False ) location_tag = Column(String, nullable=False) equipment = relationship( "StandardScope", lazy="selectin", primaryjoin="and_(OverhaulJob.location_tag == foreign(StandardScope.location_tag))", uselist=False, # Add this if it's a one-to-one relationship ) workscope_group = relationship("MasterActivity", lazy="selectin", back_populates="equipment_workscope_groups") # scope_equipment_job = relationship( # "ScopeEquipmentJob", lazy="raise", back_populates="overhaul_jobs" # ) # overhaul_activity = relationship("OverhaulActivity", lazy="raise", back_populates="overhaul_jobs")