# PostgreSQL table model for users
from sqlalchemy import Column, Integer, String, DateTime, 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)
    BirthDate = Column(DateTime, nullable=False)
    ContactNumber = Column(String, nullable=False)
    Email = Column(String, nullable=False)
    Role = Column(String, nullable=False)
    DrivingLicenseNumber = Column(String, nullable=True)
    AssignedVehicle = Column(Integer, ForeignKey("vehicle.Id"), nullable=True)
    vehicle = relationship("Vehicle", back_populates="driver")
    HashedPassword = Column(String, nullable=False)