@@ -5,3 +5,4 @@ from db.models.vehicle import Vehicle | |||||
from db.models.carpart import CarPart | from db.models.carpart import CarPart | ||||
from db.models.maintenancejob import MaintenanceJob | from db.models.maintenancejob import MaintenanceJob | ||||
from db.models.drivetask import DriveTask | from db.models.drivetask import DriveTask | ||||
from db.models.auction import Auction |
@@ -8,8 +8,9 @@ class Auction(Base): | |||||
initialPrice = Column(Integer, nullable=False) | initialPrice = Column(Integer, nullable=False) | ||||
minimalBet = Column(Integer, nullable=False) | minimalBet = Column(Integer, nullable=False) | ||||
carID = Column(Integer, ForeignKey("car.Id"), nullable=False) | |||||
carID = Column(Integer, ForeignKey("vehicle.Id"), nullable=False) | |||||
vehicle = relationship("Vehicle", back_populates="auction") | vehicle = relationship("Vehicle", back_populates="auction") | ||||
creatorId = Column(Integer, ForeignKey("user.Id"), nullable=False) | |||||
CreatedBy = relationship("User", back_populates="auctions") | CreatedBy = relationship("User", back_populates="auctions") | ||||
dateStart = Column(DateTime, nullable=False) | dateStart = Column(DateTime, nullable=False) | ||||
dateEnd = Column(DateTime, nullable=False) | dateEnd = Column(DateTime, nullable=False) | ||||
@@ -7,7 +7,7 @@ class MaintenanceJob(Base): | |||||
Id = Column(Integer, primary_key=True, index=True) | Id = Column(Integer, primary_key=True, index=True) | ||||
# a list of weak entities of class CarPart | # a list of weak entities of class CarPart | ||||
CarParts = relationship("CarPart", back_populates="parent") | CarParts = relationship("CarPart", back_populates="parent") | ||||
CreatedBy = relationship("MaintenancePerson", back_populates="maintenanceJobs") | |||||
CreatedBy = relationship("User", back_populates="maintenanceJobs") | |||||
Description = Column(String, nullable=False) | Description = Column(String, nullable=False) | ||||
Date = Column(DateTime, nullable=False) | Date = Column(DateTime, nullable=False) | ||||
MaintenanceWorker = Column(ForeignKey("user.Id"), nullable=False) | MaintenanceWorker = Column(ForeignKey("user.Id"), nullable=False) |
@@ -18,14 +18,14 @@ class User(Base): | |||||
#Admin-specific relationships | #Admin-specific relationships | ||||
CreatedAuctions = relationship("Auction", back_populates="CreatedBy") | |||||
auctions = relationship("Auction", back_populates="CreatedBy") | |||||
#Driver-specific relationships | #Driver-specific relationships | ||||
DrivingLicenseNumber = Column(String, nullable=True) | DrivingLicenseNumber = Column(String, nullable=True) | ||||
AssignedVehicle = Column(Integer, ForeignKey("vehicle.Id"), nullable=True) | AssignedVehicle = Column(Integer, ForeignKey("vehicle.Id"), nullable=True) | ||||
DriveTasks = relationship("DriveTask", back_populates="CreatedBy") | |||||
driveTasks = relationship("DriveTask", back_populates="CreatedBy") | |||||
vehicle = relationship("Vehicle", back_populates="driver") | vehicle = relationship("Vehicle", back_populates="driver") | ||||
#MaintenancePerson-specific relationships | #MaintenancePerson-specific relationships | ||||
maintenanceJobs = relationship("MaintenanceJob", back_populates="CreatedBy") | maintenanceJobs = relationship("MaintenanceJob", back_populates="CreatedBy") | ||||
#FuelingPerson-specific relationships | #FuelingPerson-specific relationships | ||||
fuelingJobs = relationship("FuelingJob", back_populates="CreatedBy") | |||||
#fuelingJobs = relationship("FuelingJob", back_populates="CreatedBy") | |||||
@@ -22,3 +22,5 @@ class Vehicle(Base): | |||||
Capacity = Column(Integer, nullable=False) | Capacity = Column(Integer, nullable=False) | ||||
DriverHistory = Column(ARRAY(Integer), nullable=True) | DriverHistory = Column(ARRAY(Integer), nullable=True) | ||||
driver = relationship("User", back_populates="vehicle") | driver = relationship("User", back_populates="vehicle") | ||||
auction = relationship("Auction", back_populates="vehicle") | |||||