17 lines
701 B
Python
17 lines
701 B
Python
from sqlalchemy import Column, Integer, String, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.models.base import Base
|
|
|
|
|
|
class User(Base):
|
|
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)
|
|
is_active = Column(Boolean, default=True)
|
|
is_superuser = Column(Boolean, default=False)
|
|
|
|
# Relationships
|
|
carts = relationship("Cart", back_populates="user", cascade="all, delete-orphan")
|
|
cart_items = relationship("CartItem", back_populates="user", cascade="all, delete-orphan") |