Add Food model

This commit is contained in:
Backend IM Bot 2025-03-28 15:56:51 +00:00
parent 0e747fdc97
commit 8a2c0c84f9

View File

@ -1,24 +1,21 @@
from sqlalchemy import Column, String, Integer, Boolean, DateTime, ForeignKey, Float, Text, Enum from sqlalchemy import Column, String, Integer, Boolean, DateTime, ForeignKey, Float, Text, JSON, Date, Time, Enum
from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from sqlalchemy.sql import func from sqlalchemy.sql import func
from core.database import Base from core.database import Base
import uuid import uuid
import enum from datetime import datetime
class FoodCategory(enum.Enum):
VEGAN = "vegan"
VEGETARIAN = "vegetarian"
NON_VEGETARIAN = "non-vegetarian"
class Food(Base): class Food(Base):
__tablename__ = "foods" __tablename__ = "foods"
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
name = Column(String, nullable=False, unique=True) name = Column(String, nullable=False)
description = Column(Text, nullable=True) description = Column(Text, nullable=True)
price = Column(Float, nullable=False) price = Column(Float, nullable=False)
category = Column(Enum(FoodCategory), nullable=False)
is_available = Column(Boolean, default=True) is_available = Column(Boolean, default=True)
category = Column(String, nullable=True)
cuisine = Column(String, nullable=True)
allergens = Column(JSON, nullable=True)
created_at = Column(DateTime, default=func.now()) created_at = Column(DateTime, default=func.now())
updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) updated_at = Column(DateTime, default=func.now(), onupdate=func.now())