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


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

    transporter_key = Column(String(23), primary_key=True, nullable=False)
    # Internal integer identifier (surrogate). The frontend continues to use transporter_key.
    transporter_id = Column(BigInteger, nullable=False, unique=True, index=True)
    name = Column(String(256), nullable=True)
    short_name = Column(String(10), nullable=True)
    responsible = Column(String(100), nullable=True)
    rfc = Column(String(30), nullable=True)
    streets = Column(String(100), nullable=True)
    postal_code = Column(String(15), nullable=True)
    city = Column(String(30), nullable=True)
    state = Column(String(30), nullable=True)
    country = Column(String(3), nullable=True)
    loader_code = Column(String(9), nullable=True)
    caat_code = Column(String(49), nullable=True)
    transport_code = Column(String(8), nullable=True)
    transport_interface_type = Column(String(20), nullable=True)
    ftp_server = Column(String(200), nullable=True)
    ftp_user = Column(String(200), nullable=True)
    ftp_password = Column(String(100), nullable=True)
    ftp_directory = Column(String(1000), nullable=True)
    filler_code = Column(String(20), nullable=True)
    has_express_line = Column(Boolean, nullable=False, server_default="false")
