Merge branch 'refactor/backend-architecture' into development
This commit is contained in:
34
api/app/features/user/models.py
Normal file
34
api/app/features/user/models.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from sqlalchemy import Column, DateTime, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.db import Base, utc_now
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
phone = Column(String, unique=True, nullable=False, index=True)
|
||||
password_hash = Column(String, nullable=False)
|
||||
email = Column(String, unique=True, nullable=True)
|
||||
openid = Column(String, unique=True, nullable=True)
|
||||
nickname = Column(String, nullable=False)
|
||||
avatar_url = Column(String, nullable=True)
|
||||
subscription_type = Column(String, default="free")
|
||||
subscription_expires_at = Column(DateTime(timezone=True), nullable=True)
|
||||
created_at = Column(DateTime(timezone=True), default=utc_now)
|
||||
birth_year = Column(Integer, nullable=True)
|
||||
birth_place = Column(String, nullable=True)
|
||||
grew_up_place = Column(String, nullable=True)
|
||||
occupation = Column(String, nullable=True)
|
||||
|
||||
conversations = relationship("Conversation", back_populates="user")
|
||||
chapters = relationship("Chapter", back_populates="user")
|
||||
books = relationship("Book", back_populates="user")
|
||||
orders = relationship("Order", back_populates="user", cascade="all, delete-orphan")
|
||||
memoir_state = relationship(
|
||||
"MemoirState", back_populates="user", uselist=False, cascade="all, delete-orphan"
|
||||
)
|
||||
refresh_tokens = relationship(
|
||||
"RefreshToken", back_populates="user", cascade="all, delete-orphan"
|
||||
)
|
||||
Reference in New Issue
Block a user