29 lines
No EOL
1 KiB
Python
29 lines
No EOL
1 KiB
Python
"""
|
|
User model for authentication and profiles
|
|
"""
|
|
|
|
from sqlalchemy import Column, Integer, String, DateTime, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String)
|
|
is_active = Column(Boolean, default=True)
|
|
is_verified = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# Relationships
|
|
collections = relationship("Collection", back_populates="owner")
|
|
decks = relationship("Deck", back_populates="owner")
|
|
|
|
def __repr__(self):
|
|
return f"<User(id={self.id}, username='{self.username}')>" |