from core.database import Base
from sqlalchemy import String, Integer
from sqlalchemy.orm import Mapped, mapped_column


class CartaPorte(Base):
    __tablename__ = "carta_porte_codes"
    __table_args__ = (
        {"schema": "public", "extend_existing": True},
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    code: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
    description: Mapped[str] = mapped_column(String(2000), nullable=False)
    similar_words: Mapped[str] = mapped_column(String(2000), nullable=True)
    is_hazardous: Mapped[int] = mapped_column(Integer, default=0)
    start_date: Mapped[str] = mapped_column(String(20), nullable=True)
    end_date: Mapped[str] = mapped_column(String(20), nullable=True)

    def __repr__(self):
        return f"<CartaPorte(code={self.code}, description={self.description[:30]}...)>"
