import uuid
from datetime import date

from sqlalchemy import Boolean, Date, Integer, String, UniqueConstraint
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column

from app.core.database import Base


class PublicHoliday(Base):
    __tablename__ = "public_holidays"
    __table_args__ = (
        UniqueConstraint("country", "state", "date", name="uq_public_holiday"),
    )

    id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    country: Mapped[str] = mapped_column(String(10), nullable=False)
    state: Mapped[str | None] = mapped_column(String(10))  # z.B. "BY", "NW" für Bundesländer
    date: Mapped[date] = mapped_column(Date, nullable=False, index=True)
    name: Mapped[str] = mapped_column(String(255), nullable=False)
    year: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
    is_high_rate: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)

    def __repr__(self) -> str:
        return f"<PublicHoliday {self.name} {self.date}>"
