
- Setup project structure and FastAPI application - Create SQLAlchemy models for users, products, carts, and orders - Implement Alembic migrations - Add CRUD operations and endpoints for all resources - Setup authentication with JWT - Add role-based access control - Update documentation
23 lines
818 B
Python
23 lines
818 B
Python
from datetime import datetime
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
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)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String, index=True)
|
|
is_active = Column(Boolean, default=True)
|
|
is_superuser = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
orders = relationship("Order", back_populates="user")
|
|
cart_items = relationship("CartItem", back_populates="user")
|