29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Float, DateTime, Boolean, Text, ForeignKey, JSON
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
from app.database.database import Base
|
|
|
|
|
|
class Product(Base):
|
|
__tablename__ = "product"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, index=True)
|
|
description = Column(Text)
|
|
price = Column(Float)
|
|
discount_price = Column(Float, nullable=True)
|
|
category_id = Column(Integer, ForeignKey("category.id"))
|
|
gender = Column(String) # men, women
|
|
brand = Column(String)
|
|
sizes = Column(JSON) # ["S", "M", "L", "XL", ...]
|
|
colors = Column(JSON) # ["Red", "Blue", ...]
|
|
stock = Column(Integer, default=0)
|
|
images = Column(JSON) # Array of image URLs
|
|
is_featured = Column(Boolean, default=False)
|
|
is_on_sale = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
category = relationship("Category")
|
|
cart_items = relationship("CartItem", back_populates="product")
|
|
order_items = relationship("OrderItem", back_populates="product")
|