"""User model - represents both humans and AI worker accounts.""" from sqlalchemy import Column, String, Boolean, Integer, Text, ForeignKey from app.models.base import Base, TimestampMixin, TenantMixin class User(Base, TimestampMixin, TenantMixin): """A user can be a human or an AI worker proxy. - Humans: have email + password, role determines permissions - AI: linked to AIWorker via worker_id, role is typically 'worker' Roles: super_admin, tenant_admin, project_manager, reviewer, worker """ __tablename__ = "users" id = Column(Integer, primary_key=True, autoincrement=True) email = Column(String(255), nullable=False, index=True) username = Column(String(100), nullable=False) hashed_password = Column(String(255), nullable=True) # null for AI users role = Column(String(50), nullable=False, default="worker") # "human" or "ai" user_type = Column(String(20), nullable=False, default="human") # If AI user, link to the AIWorker record worker_id = Column(Integer, ForeignKey("ai_workers.id"), nullable=True) is_active = Column(Boolean, default=True, nullable=False) avatar = Column(String(500), nullable=True) phone = Column(String(50), nullable=True) def __repr__(self): return f""