|
12345678910111213141516171819202122232425262728293031 |
- # PostgreSQL table model for users
- from sqlalchemy import Column, Integer, String, ForeignKey
- from sqlalchemy.orm import relationship
- from db.base import Base
-
-
- class User(Base):
- Id = Column(Integer, primary_key=True, index=True)
- Name = Column(String, nullable=False)
- MiddleName = Column(String, nullable=True)
- LastName = Column(String, nullable=False)
- GovernmentId = Column(String, nullable=False)
- Address = Column(String, nullable=False)
- ContactNumber = Column(String, nullable=False)
- Email = Column(String, nullable=False)
- Role = Column(String, nullable=False)
- HashedPassword = Column(String, nullable=False)
-
-
- #Admin-specific relationships
- 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")
- vehicle = relationship("Vehicle", back_populates="driver")
- #MaintenancePerson-specific relationships
- maintenanceJobs = relationship("MaintenanceJob", back_populates="CreatedBy")
- #FuelingPerson-specific relationships
- fuelingTasks = relationship("FuelingTask", back_populates="CreatedBy", foreign_keys="FuelingTask.CreatedById")
-
|