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


class IdentifierCatalog(Base):
    __tablename__ = "identifiers"
    __table_args__ = (
        PrimaryKeyConstraint("key", name="identifiers_pkey"),
        {"schema": "public", "extend_existing": True},
    )

    key: Mapped[str] = mapped_column(
        String(10), primary_key=True, nullable=False)  # clave del identificador
    description: Mapped[str] = mapped_column(
        String(2000), nullable=False
    )  # descripción
    level: Mapped[str] = mapped_column(
        String(1), nullable=False
    )  # nivel (G, P, etc)
    complement: Mapped[str] = mapped_column(
        String(5000), nullable=False
    )  # complemento / instrucciones

    def __repr__(self):
        return f"<IdentifierCatalog(key={self.key}, level={self.level})>"
