
Features: - Extended User model with profile fields (first_name, last_name, phone, bio, preferred_language, timezone) - Complete profile endpoints for viewing and updating user information - Password update functionality with current password verification - Email update functionality with duplicate email checking - Account deletion endpoint - Database migration for new profile fields - Enhanced logging and error handling for all profile operations - Updated API documentation with profile endpoints Profile fields include: - Personal information (name, phone, bio) - Preferences (language, timezone) - Account management (password, email updates) - Timestamps (created_at, updated_at)
19 lines
791 B
Python
19 lines
791 B
Python
from sqlalchemy import Column, Integer, String, DateTime
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
password_hash = Column(String, nullable=False)
|
|
first_name = Column(String, nullable=True)
|
|
last_name = Column(String, nullable=True)
|
|
phone = Column(String, nullable=True)
|
|
bio = Column(String, nullable=True)
|
|
preferred_language = Column(String, default="en")
|
|
timezone = Column(String, default="UTC")
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) |