from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
from core.database import Base
from sqlalchemy import BigInteger, Column, ForeignKey, ForeignKeyConstraint, Integer, String


class Driver(Base, TenantScopedMixin, TimestampMixin):
    __tablename__ = "driver"
    __table_args__ = (
        {"schema": "a76"},
    )

    transporter_key = Column(
        String(30),
        ForeignKey("a76.transporter.transporter_key", ondelete="CASCADE"),
        primary_key=True,
        nullable=False,
    )
    line = Column(Integer, primary_key=True, nullable=False)
    # Internal integer surrogate ID. The frontend continues to use transporter_key/line.
    driver_id = Column(BigInteger, nullable=False, unique=True, index=True)
    driver_name = Column(String(80), nullable=True)
    license_number = Column(String(29), nullable=True)
    express_line_id = Column(String(17), nullable=True)
    ace_id = Column(String(20), nullable=True)
    birth_date = Column(Integer, nullable=True)
    gender = Column(String(1), nullable=True)
    birth_country = Column(String(3), nullable=True)
    hazardous_material_auth = Column(String(2), nullable=True)
    hazardous_material_state = Column(String(30), nullable=True)
    first_name = Column(String(20), nullable=True)
    last_name = Column(String(20), nullable=True)
    id_key1 = Column(String(40), nullable=True)
    id_number1 = Column(String(20), nullable=True)
    id_state1 = Column(String(30), nullable=True)
    id_country1 = Column(String(3), nullable=True)
    id_key2 = Column(String(40), nullable=True)
    id_number2 = Column(String(20), nullable=True)
    id_state2 = Column(String(30), nullable=True)
    id_country2 = Column(String(3), nullable=True)
    badge_number = Column(String(20), nullable=True)
    class_type = Column(String(1), nullable=True)
    unique_badge_number = Column(String(100), nullable=True)
