21 lines
819 B
Python
21 lines
819 B
Python
"""User model."""
|
|
|
|
from sqlalchemy import Column, String, Boolean, Integer
|
|
from sqlalchemy.orm import relationship
|
|
from app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class User(Base, TimestampMixin):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String(255), unique=True, index=True, nullable=False)
|
|
password_hash = Column(String(255), nullable=False)
|
|
first_name = Column(String(100), nullable=False)
|
|
last_name = Column(String(100), nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
is_superadmin = Column(Boolean, default=False)
|
|
|
|
user_roles = relationship("UserRole", back_populates="user", cascade="all, delete-orphan")
|
|
user_module_roles = relationship("UserModuleRole", back_populates="user", cascade="all, delete-orphan")
|