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


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

    trailer_number = Column(String(20), primary_key=True, nullable=False)
    # Internal integer identifier (surrogate). The frontend continues to use trailer_number.
    trailer_id = Column(BigInteger, nullable=False, unique=True, index=True)
    ace_trailer_number = Column(String(10), nullable=True)
    trailer_type_key = Column(
        String(2), ForeignKey("public.trailer_type.trailer_type_key"), nullable=True
    )
    seal = Column(String(15), nullable=True)
    entity_code = Column(String(1), nullable=True)
    plate_number = Column(String(17), nullable=True)
    state = Column(String(30), nullable=True)
    country = Column(String(3), nullable=True)
    container_key = Column(String(3), nullable=True)
