user.py 841 B

12345678910111213141516171819
  1. from datetime import datetime
  2. from sqlalchemy import DateTime, String
  3. from sqlalchemy.dialects.sqlite import JSON
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from core_db import AuditMixin, Base, TenantMixin, VersionMixin
  6. from core_shared import JSONValue
  7. class User(TenantMixin, AuditMixin, VersionMixin, Base):
  8. __tablename__ = "auth_user"
  9. username: Mapped[str] = mapped_column(String(128), index=True)
  10. display_name: Mapped[str | None] = mapped_column(String(128), nullable=True)
  11. email: Mapped[str | None] = mapped_column(String(256), nullable=True, index=True)
  12. status: Mapped[str] = mapped_column(String(32), default="active", index=True)
  13. metadata_json: Mapped[dict[str, JSONValue]] = mapped_column(JSON, default=dict)
  14. last_login_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)