From 245bd2de862755ff1ef22a009f2436f855da3844 Mon Sep 17 00:00:00 2001
From: Madiwka <madi.turgunov.03@gmail.com>
Date: Sun, 22 Oct 2023 13:46:00 +0600
Subject: [PATCH] Fix

---
 app/db/base.py                  | 1 +
 app/db/models/auction.py        | 3 ++-
 app/db/models/fuelingtask.py    | 0
 app/db/models/maintenancejob.py | 2 +-
 app/db/models/user.py           | 6 +++---
 app/db/models/vehicle.py        | 2 ++
 6 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 app/db/models/fuelingtask.py

diff --git a/app/db/base.py b/app/db/base.py
index 57fff10..e2eb3d3 100644
--- a/app/db/base.py
+++ b/app/db/base.py
@@ -5,3 +5,4 @@ from db.models.vehicle import Vehicle
 from db.models.carpart import CarPart
 from db.models.maintenancejob import MaintenanceJob
 from db.models.drivetask import DriveTask
+from db.models.auction import Auction
diff --git a/app/db/models/auction.py b/app/db/models/auction.py
index 0f6ed49..8456626 100644
--- a/app/db/models/auction.py
+++ b/app/db/models/auction.py
@@ -8,8 +8,9 @@ class Auction(Base):
     
     initialPrice = 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")
+    creatorId = Column(Integer, ForeignKey("user.Id"), nullable=False)
     CreatedBy = relationship("User", back_populates="auctions")
     dateStart = Column(DateTime, nullable=False)
     dateEnd = Column(DateTime, nullable=False)
diff --git a/app/db/models/fuelingtask.py b/app/db/models/fuelingtask.py
new file mode 100644
index 0000000..e69de29
diff --git a/app/db/models/maintenancejob.py b/app/db/models/maintenancejob.py
index 6914241..12dbc41 100644
--- a/app/db/models/maintenancejob.py
+++ b/app/db/models/maintenancejob.py
@@ -7,7 +7,7 @@ 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")
-    CreatedBy = relationship("MaintenancePerson", back_populates="maintenanceJobs")
+    CreatedBy = relationship("User", back_populates="maintenanceJobs")
     Description = Column(String, nullable=False)
     Date = Column(DateTime, nullable=False)
     MaintenanceWorker = Column(ForeignKey("user.Id"), nullable=False)
diff --git a/app/db/models/user.py b/app/db/models/user.py
index c518fb1..9363676 100644
--- a/app/db/models/user.py
+++ b/app/db/models/user.py
@@ -18,14 +18,14 @@ class User(Base):
     
     
     #Admin-specific relationships
-    CreatedAuctions = relationship("Auction", back_populates="CreatedBy")
+    auctions = relationship("Auction", back_populates="CreatedBy")
     #Driver-specific relationships
     DrivingLicenseNumber = Column(String, 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")
     #MaintenancePerson-specific relationships
     maintenanceJobs = relationship("MaintenanceJob", back_populates="CreatedBy")
     #FuelingPerson-specific relationships
-    fuelingJobs = relationship("FuelingJob", back_populates="CreatedBy")
+    #fuelingJobs = relationship("FuelingJob", back_populates="CreatedBy")
 
diff --git a/app/db/models/vehicle.py b/app/db/models/vehicle.py
index 1d6bf86..e5a390b 100644
--- a/app/db/models/vehicle.py
+++ b/app/db/models/vehicle.py
@@ -22,3 +22,5 @@ class Vehicle(Base):
     Capacity = Column(Integer, nullable=False)
     DriverHistory = Column(ARRAY(Integer), nullable=True)
     driver = relationship("User", back_populates="vehicle")
+    auction = relationship("Auction", back_populates="vehicle")
+