From 2102e1d855a6ae8047375c94e1e988d5f130f1d2 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 16:00:59 +0000 Subject: [PATCH] Add Food model --- models/food.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/models/food.py b/models/food.py index bc8add6..0bbc26e 100644 --- a/models/food.py +++ b/models/food.py @@ -1,19 +1,20 @@ -from sqlalchemy import Column, String, Integer, ForeignKey, Float, DateTime +from sqlalchemy import Column, String, Integer, Float, DateTime, ForeignKey from sqlalchemy.orm import relationship -from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.sql import func +from sqlalchemy.dialects.postgresql import UUID from core.database import Base import uuid -class FoodCategory(Base): - __tablename__ = "food_categories" +class Restaurant(Base): + __tablename__ = "restaurants" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) - name = Column(String, nullable=False, unique=True) + name = Column(String, nullable=False) + address = Column(String, nullable=False) created_at = Column(DateTime, default=func.now()) updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) - foods = relationship("Food", back_populates="category") + menu = relationship("Food", back_populates="restaurant") class Food(Base): __tablename__ = "foods" @@ -22,8 +23,8 @@ class Food(Base): name = Column(String, nullable=False) description = Column(String, nullable=True) price = Column(Float, nullable=False) - category_id = Column(UUID, ForeignKey("food_categories.id"), nullable=False) + restaurant_id = Column(UUID(as_uuid=True), ForeignKey("restaurants.id"), nullable=False) created_at = Column(DateTime, default=func.now()) updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) - category = relationship("FoodCategory", back_populates="foods") \ No newline at end of file + restaurant = relationship("Restaurant", back_populates="menu") \ No newline at end of file