from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
from core.database import Base
from sqlalchemy import (
    ForeignKeyConstraint,
    Integer,
    PrimaryKeyConstraint,
    String,
    UniqueConstraint,
)
from sqlalchemy.orm import Mapped, mapped_column


class FractionRuleOctave(Base, TenantScopedMixin, TimestampMixin):
    __tablename__ = "fraction_rule_octave"
    __table_args__ = (
        PrimaryKeyConstraint("id", name="fraction_rule_octave_pkey"),
        UniqueConstraint(
            "tenant_id",
            "company_id",
            "permission",
            "line",
            "fraction",
            name="uq_fraction_rule_octave_permission_line_fraction",
        ),
        {"schema": "a76"},
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)

    permission: Mapped[str] = mapped_column(String(20))
    line: Mapped[int] = mapped_column(Integer)
    fraction: Mapped[str] = mapped_column(String(10))
