from __future__ import annotations

from sqlalchemy import CheckConstraint, ForeignKey, Index, Integer, Numeric, String, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship

from src.db.base import Base


class Sequestration(Base):
    __tablename__ = "sequestration"
    __table_args__ = (
        CheckConstraint("actor IN ('DFIP','SSP_GO')", name="ck_v3_sequestration_actor"),
        UniqueConstraint("line_id", "actor", name="uq_v3_sequestration_line_actor"),
        Index("ix_v3_sequestration_line_actor", "line_id", "actor"),
        {"schema": "v3"},
    )

    id: Mapped[int] = mapped_column(primary_key=True)
    line_id: Mapped[int] = mapped_column(Integer, ForeignKey("v3.budget_line.id"))
    actor: Mapped[str] = mapped_column(String)
    adj_q1: Mapped[float | None] = mapped_column(Numeric)
    adj_q2: Mapped[float | None] = mapped_column(Numeric)
    adj_q3: Mapped[float | None] = mapped_column(Numeric)
    adj_q4: Mapped[float | None] = mapped_column(Numeric)
    justification: Mapped[str | None] = mapped_column(String)

#     line = relationship("BudgetLine")
