from sqlalchemy import Index, text from sqlalchemy.orm import Mapped, mapped_column from fooder.domain.base import Base, CommonMixin, SoftDeleteMixin class Product(Base, CommonMixin, SoftDeleteMixin): """Product.""" __table_args__ = ( Index( "ix_product_barcode", "barcode", unique=True, postgresql_where=text("deleted_at IS NULL"), sqlite_where=text("deleted_at IS NULL"), ), ) name: Mapped[str] protein: Mapped[float] carb: Mapped[float] fat: Mapped[float] fiber: Mapped[float] calories: Mapped[float] barcode: Mapped[str | None] = mapped_column(default=None)