From 4d31e63cb804985421844aac3d5f80b0b1e700ec Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 09:41:21 +0000 Subject: [PATCH] Add Meal model --- models/meal.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/models/meal.py b/models/meal.py index e5f05ba..9c4dff5 100644 --- a/models/meal.py +++ b/models/meal.py @@ -1,29 +1,21 @@ -from sqlalchemy import Column, String, Integer, Float, DateTime, ForeignKey +from sqlalchemy import Column, String, Integer, Boolean, DateTime, ForeignKey, Float, Text, JSON, Date, Time, Enum +from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from sqlalchemy.sql import func -from sqlalchemy.dialects.postgresql import UUID from core.database import Base import uuid +from datetime import datetime class Meal(Base): __tablename__ = "meals" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) name = Column(String, nullable=False) - description = Column(String, nullable=True) + description = Column(Text, nullable=True) price = Column(Float, nullable=False) - category_id = Column(UUID(as_uuid=True), ForeignKey('categories.id'), nullable=False) + is_available = Column(Boolean, default=True) + category = Column(String, nullable=True) + cuisine = Column(String, nullable=True) + dietary_restrictions = Column(JSON, nullable=True) created_at = Column(DateTime, default=func.now()) - updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) - - category = relationship("Category", back_populates="meals") - -class Category(Base): - __tablename__ = "categories" - - id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) - name = Column(String, nullable=False, unique=True) - created_at = Column(DateTime, default=func.now()) - updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) - - meals = relationship("Meal", back_populates="category") \ No newline at end of file + updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) \ No newline at end of file