brands-in-shops feature implemented

This commit is contained in:
2025-05-27 23:41:04 +02:00
parent 7037be370e
commit 2846bcbb1c
9 changed files with 559 additions and 36 deletions

View File

@@ -17,6 +17,19 @@ shopping_event_products = Table(
Column('price', Float, nullable=False) # Price of this product at the time of this shopping event
)
class BrandInShop(Base):
__tablename__ = "brands_in_shops"
id = Column(Integer, primary_key=True, index=True)
shop_id = Column(Integer, ForeignKey("shops.id"), nullable=False)
brand_id = Column(Integer, ForeignKey("brands.id"), nullable=False)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Relationships
shop = relationship("Shop", back_populates="brands_in_shop")
brand = relationship("Brand", back_populates="shops_with_brand")
class Brand(Base):
__tablename__ = "brands"
@@ -27,6 +40,7 @@ class Brand(Base):
# Relationships
products = relationship("Product", back_populates="brand")
shops_with_brand = relationship("BrandInShop", back_populates="brand")
class GroceryCategory(Base):
__tablename__ = "grocery_categories"
@@ -82,6 +96,7 @@ class Shop(Base):
# Relationships
shopping_events = relationship("ShoppingEvent", back_populates="shop")
brands_in_shop = relationship("BrandInShop", back_populates="shop")
class ShoppingEvent(Base):
__tablename__ = "shopping_events"