from __future__ import annotations

from sqlalchemy import Integer, String
from sqlalchemy.orm import Mapped, mapped_column

from app.core.db.common import CommonBase


class ClientAssociation(CommonBase):
    __tablename__ = "client_associations"

    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
    client_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
    association_type: Mapped[str] = mapped_column(String(50), nullable=False, default="firm")
    firm_tenant_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
    consultant_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
    partner_user_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
    created_source: Mapped[str] = mapped_column(String(50), nullable=False, default="system_admin")