from sqlalchemy import Column, String, Integer, Float, Text, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.sql import func from core.database import Base import uuid class Food(Base): __tablename__ = "foods" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) name = Column(String, nullable=False) description = Column(Text, nullable=True) price = Column(Float, nullable=False) category_id = Column(UUID(as_uuid=True), ForeignKey("categories.id"), nullable=False) category = relationship("Category", back_populates="foods") created_at = Column(DateTime, default=func.now()) updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) class Category(Base): __tablename__ = "categories" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) name = Column(String, nullable=False, unique=True) description = Column(Text, nullable=True) foods = relationship("Food", back_populates="category") created_at = Column(DateTime, default=func.now()) updated_at = Column(DateTime, default=func.now(), onupdate=func.now())