first commit
This commit is contained in:
23
backend/app/models/user.py
Normal file
23
backend/app/models/user.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Enum
|
||||
from sqlalchemy.sql import func
|
||||
from app.models import Base
|
||||
from app.config import TABLE_PREFIX
|
||||
import enum
|
||||
|
||||
class UserRole(str, enum.Enum):
|
||||
admin = "admin"
|
||||
user = "user"
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = f"{TABLE_PREFIX}users"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
email = Column(String(200), unique=True, index=True, nullable=False)
|
||||
ad_username = Column(String(100), nullable=True) # Added to satisfy DB constraint
|
||||
department = Column(String(100), nullable=True) # Added to satisfy DB constraint
|
||||
password_hash = Column("local_password", String(255), nullable=True)
|
||||
display_name = Column(String(100), nullable=True)
|
||||
# language = Column(String(10), default="zh-TW") # Not in DB
|
||||
role = Column(String(20), default="user") # Simplified from Enum
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
Reference in New Issue
Block a user