Spaces:
Sleeping
Sleeping
File size: 899 Bytes
d623240 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from __future__ import annotations
from enum import Enum
from uuid import uuid4
from sqlalchemy import Boolean, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.db.base import Base, TimestampMixin
class UserRole(str, Enum):
ADMIN = "admin"
USER = "user"
class User(TimestampMixin, Base):
__tablename__ = "users"
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid4()))
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
full_name: Mapped[str] = mapped_column(String(255))
password_hash: Mapped[str] = mapped_column(String(255))
role: Mapped[str] = mapped_column(String(32), default=UserRole.USER.value)
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
predictions = relationship("PredictionLog", back_populates="user", cascade="all, delete-orphan")
|