19 lines
632 B
Python
19 lines
632 B
Python
from enum import Enum
|
|
from sqlalchemy import String, Boolean, Enum as SAEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.db import Base
|
|
|
|
class UserRole(str, Enum):
|
|
ADMIN = "admin"
|
|
USER = "user"
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
|
password_hash: Mapped[str] = mapped_column(String(255))
|
|
role: Mapped[UserRole] = mapped_column(SAEnum(UserRole), default=UserRole.USER)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|