"""
Modelo para el catálogo de claves FDA
"""
from typing import Optional
from sqlalchemy import String, Integer, UniqueConstraint, PrimaryKeyConstraint
from sqlalchemy.orm import Mapped, mapped_column
from core.database import Base
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin


class FDACatalog(Base, TenantScopedMixin, TimestampMixin):
    """Catálogo de claves FDA"""
    __tablename__ = "fda_catalog"
    __table_args__ = (
        PrimaryKeyConstraint("id", name="fda_catalog_pkey"),
        UniqueConstraint('tenant_id', 'company_id', 'fda_key', name='idx_fda_catalog_unique'),
        {'schema': 'a76'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    fda_key: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
    description: Mapped[str] = mapped_column(String(500), nullable=False, index=True)
    fda_code: Mapped[Optional[str]] = mapped_column(String(50))
    requirements: Mapped[Optional[str]] = mapped_column(String(500))
    manufacturer_number: Mapped[Optional[str]] = mapped_column(String(50))
    country_of_production: Mapped[Optional[str]] = mapped_column(String(100))
    storage_status: Mapped[Optional[str]] = mapped_column(String(100))
    warehouse_code: Mapped[Optional[str]] = mapped_column(String(20))
    call_atl: Mapped[Optional[str]] = mapped_column(String(20))
