Spaces:
Sleeping
Sleeping
Upload app/models/product.py
Browse files- app/models/product.py +3 -0
app/models/product.py
CHANGED
|
@@ -53,5 +53,8 @@ class Category(Base):
|
|
| 53 |
name_en = Column(String(255), nullable=False)
|
| 54 |
icon = Column(String(50), nullable=True)
|
| 55 |
sort_order = Column(Integer, default=0, nullable=False)
|
|
|
|
| 56 |
|
|
|
|
|
|
|
| 57 |
products = relationship("Product", back_populates="category")
|
|
|
|
| 53 |
name_en = Column(String(255), nullable=False)
|
| 54 |
icon = Column(String(50), nullable=True)
|
| 55 |
sort_order = Column(Integer, default=0, nullable=False)
|
| 56 |
+
parent_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
| 57 |
|
| 58 |
+
parent = relationship("Category", remote_side=[id], back_populates="subcategories")
|
| 59 |
+
subcategories = relationship("Category", back_populates="parent", cascade="all, delete-orphan")
|
| 60 |
products = relationship("Product", back_populates="category")
|