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


class MaterialType(Base):
    __tablename__ = "material_types"  # STipoMat QTipoActFijo
    __table_args__ = (
        PrimaryKeyConstraint("key", name="material_types_pkey"),
        {"schema": "public", "extend_existing": True},
    )

    key: Mapped[str] = mapped_column(
        String(10), primary_key=True, nullable=False)  # clave del material
    type: Mapped[str] = mapped_column(String(15), nullable=False)  # tipo
    description: Mapped[str] = mapped_column(
        String(256), nullable=False
    )  # descripción oficial (en español)

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