Files
auto-virtual-tryon/app/infra/db/models/order.py

38 lines
1.5 KiB
Python

"""Order ORM model."""
from sqlalchemy import Enum, Integer
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.domain.enums import CustomerLevel, OrderStatus, ServiceMode
from app.infra.db.base import Base, TimestampMixin
class OrderORM(TimestampMixin, Base):
"""Persisted order record."""
__tablename__ = "orders"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
customer_level: Mapped[CustomerLevel] = mapped_column(
Enum(CustomerLevel, native_enum=False),
nullable=False,
)
service_mode: Mapped[ServiceMode] = mapped_column(
Enum(ServiceMode, native_enum=False),
nullable=False,
)
status: Mapped[OrderStatus] = mapped_column(
Enum(OrderStatus, native_enum=False),
nullable=False,
default=OrderStatus.CREATED,
)
model_id: Mapped[int] = mapped_column(Integer, nullable=False)
pose_id: Mapped[int | None] = mapped_column(Integer, nullable=True)
garment_asset_id: Mapped[int] = mapped_column(Integer, nullable=False)
scene_ref_asset_id: Mapped[int | None] = mapped_column(Integer, nullable=True)
final_asset_id: Mapped[int | None] = mapped_column(Integer, nullable=True)
assets = relationship("AssetORM", back_populates="order", lazy="selectin")
review_tasks = relationship("ReviewTaskORM", back_populates="order", lazy="selectin")
workflow_runs = relationship("WorkflowRunORM", back_populates="order", lazy="selectin")