from __future__ import annotations from typing import ClassVar, Optional from sqlmodel import Field, SQLModel class PropertyDetailsSpatialRow(SQLModel, table=True): """Per-UPRN cache of the Ordnance Survey spatial reference data. The OS Open-UPRN set is tens of millions of rows — too large for Postgres — so Ingestion resolves it from S3 and writes the row it used here, keyed by UPRN (one shared row per UPRN, not per Property). The front-end reads the planning flags off this table to show why a Property did or did not get a given measure; Modelling hydrates them onto the Property (ADR-0020). Coords are retained for parity with the legacy ``property_details_spatial`` shape. """ __tablename__: ClassVar[str] = "property_details_spatial" # pyright: ignore[reportIncompatibleVariableOverride] id: Optional[int] = Field(default=None, primary_key=True) uprn: int = Field(index=True, unique=True) x_coordinate: Optional[float] = Field(default=None) y_coordinate: Optional[float] = Field(default=None) latitude: Optional[float] = Field(default=None) longitude: Optional[float] = Field(default=None) conservation_status: Optional[bool] = Field(default=None) is_listed_building: Optional[bool] = Field(default=None) is_heritage_building: Optional[bool] = Field(default=None)