38 lines
1.8 KiB
Python
38 lines
1.8 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from sqlalchemy import String, DateTime, Enum as SAEnum, BigInteger
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
from app.database import Base
|
|
import enum
|
|
|
|
|
|
class ProcessingStatus(str, enum.Enum):
|
|
pending = "pending"
|
|
processing = "processing"
|
|
completed = "completed"
|
|
failed = "failed"
|
|
|
|
|
|
class CadFile(Base):
|
|
__tablename__ = "cad_files"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
original_name: Mapped[str] = mapped_column(String(500), nullable=False)
|
|
stored_path: Mapped[str] = mapped_column(String(1000), nullable=False)
|
|
file_hash: Mapped[str] = mapped_column(String(64), unique=True, nullable=False, index=True)
|
|
file_size: Mapped[int] = mapped_column(BigInteger, nullable=True)
|
|
parsed_objects: Mapped[dict] = mapped_column(JSONB, nullable=True)
|
|
thumbnail_path: Mapped[str] = mapped_column(String(1000), nullable=True)
|
|
gltf_path: Mapped[str] = mapped_column(String(1000), nullable=True)
|
|
processing_status: Mapped[ProcessingStatus] = mapped_column(
|
|
SAEnum(ProcessingStatus), default=ProcessingStatus.pending, nullable=False
|
|
)
|
|
error_message: Mapped[str] = mapped_column(String(2000), nullable=True)
|
|
render_log: Mapped[dict] = mapped_column(JSONB, nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
|
|
|
order_items: Mapped[list["OrderItem"]] = relationship("OrderItem", back_populates="cad_file")
|
|
products: Mapped[list["Product"]] = relationship("Product", back_populates="cad_file")
|