from typing import Optional

from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
from core.database import Base
from sqlalchemy import (
    Index,
    Integer,
    PrimaryKeyConstraint,
    String,
)
from sqlalchemy.orm import Mapped, mapped_column


class ManifestDriver(Base, TenantScopedMixin, TimestampMixin):
    __tablename__ = "manifest_drivers"
    __table_args__ = (
        PrimaryKeyConstraint("manifest_number", "driver_name", name="manifest_drivers_pkey"),
        Index("idx_manifest_drivers_manifest_number", "manifest_number"),
        {"schema": "a76"},
    )

    manifest_number: Mapped[str] = mapped_column(String(15))
    driver_name: Mapped[str] = mapped_column(String(80))
    driver_type: Mapped[Optional[str]] = mapped_column(String(1), nullable=True)
    address_1: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
    address_2: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
    city: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)
    state: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)
    postal_code: Mapped[Optional[str]] = mapped_column(String(15), nullable=True)
    country: Mapped[Optional[str]] = mapped_column(String(3), nullable=True)
