from sqlalchemy import Column, Integer, String, DateTime, ForeignKey from sqlalchemy.orm import relationship from db.base import Base class MaintenanceJob(Base): Id = Column(Integer, primary_key=True, index=True) # a list of weak entities of class CarPart CarParts = relationship("CarPart", back_populates="parent") FinishedBy = relationship("User", back_populates="maintenanceJobs", foreign_keys="MaintenanceJob.MaintenanceWorker") VehicleID = Column(ForeignKey("vehicle.Id"), nullable=False) Vehicle = relationship("Vehicle", back_populates="maintenanceJobs") VehicleDriverId = Column(ForeignKey("user.Id"), nullable=False) Description = Column(String, nullable=False) Date = Column(DateTime, nullable=False) MaintenanceWorker = Column(ForeignKey("user.Id"), nullable=True) Status = Column(String, nullable=False)