from sqlalchemy import Column, String, Integer, Float, DateTime, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.sql import func from sqlalchemy.dialects.postgresql import UUID from core.database import Base import uuid class Restaurant(Base): __tablename__ = "restaurants" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) 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()) menu = relationship("Food", back_populates="restaurant") class Food(Base): __tablename__ = "foods" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) name = Column(String, nullable=False) description = Column(String, nullable=True) price = Column(Float, 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()) restaurant = relationship("Restaurant", back_populates="menu")