You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
|
|
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
|
|
from .enums import OverhaulStatus
|
|
|
|
|
|
class OverhaulHistory(Base, DefaultMixin):
|
|
__tablename__ = "oh_tr_overhaul_history"
|
|
|
|
scope_id = Column(UUID(as_uuid=True), ForeignKey(
|
|
"oh_scope.id"), nullable=True)
|
|
schedule_start_date = Column(DateTime(timezone=True))
|
|
schedule_end_date = Column(DateTime(timezone=True))
|
|
total_cost = Column(Float, nullable=False, default=0)
|
|
status = Column(String, nullable=False, default=OverhaulStatus.PLANNED)
|
|
maximo_id = Column(String, nullable=True,
|
|
comment="Id From MAXIMO regarding overhaul schedule")
|
|
|
|
equipments = relationship("OverhaulHistoryEquip",
|
|
back_populates="overhaul_history",
|
|
cascade="all, delete-orphan")
|
|
|
|
|
|
class OverhaulHistoryEquip(Base, DefaultMixin):
|
|
__tablename__ = "oh_tr_overhaul_history_equip"
|
|
|
|
assetnum = Column(String(10), nullable=False)
|
|
overhaul_history_id = Column(
|
|
UUID(as_uuid=True), ForeignKey("oh_tr_overhaul_history.id"), nullable=False)
|
|
|
|
# Relationship to OverhaulHistory
|
|
overhaul_history = relationship("OverhaulHistory",
|
|
back_populates="equipments")
|