from datetime import datetime from uuid import uuid4 from core_db import AuditMixin, Base from sqlalchemy import DateTime, String from sqlalchemy.orm import Mapped, mapped_column class RoleAssignment(Base, AuditMixin): __tablename__ = "auth_role_assignment" id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid4())) user_id: Mapped[str] = mapped_column(String(36), index=True) role_id: Mapped[str] = mapped_column(String(36), index=True) status: Mapped[str] = mapped_column(String(32), default="active", index=True) scope_type: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True) scope_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True) expires_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)