from core.database import Base
from sqlalchemy import Boolean, PrimaryKeyConstraint, SmallInteger, String
from sqlalchemy.orm import Mapped, mapped_column


class Sector(Base):
    __tablename__ = "sectors"  # GSectores
    __table_args__ = (
        PrimaryKeyConstraint("key", name="sectors_pkey"),
        {"schema": "public", "extend_existing": True},  # opcional
    )

    key: Mapped[str] = mapped_column(
        String(8), nullable=False)  # clave del sector
    description: Mapped[str] = mapped_column(
        String(150), nullable=False
    )  # descripción oficial (en español)
    authorized: Mapped[bool] = mapped_column(
        Boolean
    )  # True = autorizado, False = no autorizado

    def __repr__(self):
        return f"<Sector(key={self.key}, description={self.description}, authorized={self.authorized})>"
