Newer
Older
vmk-360-data_collector / src / vmk_data_collector / models / property_image.py
from sqlalchemy import ForeignKey, Integer, SmallInteger, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from vmk_data_collector.db.base import Base
from vmk_data_collector.domain.enums import ImageAnalysisStatus, ImageDownloadStatus


class PropertyImage(Base):
    __tablename__ = "property_images"

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    property_id: Mapped[int] = mapped_column(
        ForeignKey("property_listings.id", ondelete="CASCADE"), nullable=False
    )
    url: Mapped[str] = mapped_column(Text, nullable=False)
    local_path: Mapped[str | None] = mapped_column(String(512))
    hash: Mapped[str | None] = mapped_column(String(64))
    file_size: Mapped[int | None] = mapped_column(Integer)
    width: Mapped[int | None] = mapped_column(SmallInteger)
    height: Mapped[int | None] = mapped_column(SmallInteger)
    download_status: Mapped[ImageDownloadStatus] = mapped_column(
        default=ImageDownloadStatus.pending
    )
    ai_description: Mapped[str | None] = mapped_column(Text)
    analysis_status: Mapped[ImageAnalysisStatus] = mapped_column(
        default=ImageAnalysisStatus.pending
    )
    order_index: Mapped[int] = mapped_column(SmallInteger, default=0)