diff --git a/infrastructure/postgres/epc_property_table.py b/infrastructure/postgres/epc_property_table.py index 512621d6c..f77128799 100644 --- a/infrastructure/postgres/epc_property_table.py +++ b/infrastructure/postgres/epc_property_table.py @@ -1,7 +1,7 @@ from __future__ import annotations from typing import ClassVar, Optional, Union -from sqlalchemy import Column +from sqlalchemy import BigInteger, Column from sqlalchemy import Enum as SAEnum from sqlalchemy.dialects.postgresql import JSONB from sqlmodel import SQLModel, Field @@ -36,7 +36,12 @@ class EpcPropertyModel(SQLModel, table=True): source: str = Field(default="lodged") # Identity / admin - uprn: Optional[int] = Field(default=None) + # BIGINT: real 12-digit UPRNs overflow int32 (the FE `property.uprn` is + # already bigint). SQLModel maps `int` -> INTEGER by default, so pin the + # column type or every real-UPRN insert hard-fails NumericValueOutOfRange. + uprn: Optional[int] = Field( + default=None, sa_column=Column(BigInteger, nullable=True) + ) uprn_source: Optional[str] = Field(default=None) report_reference: Optional[str] = Field(default=None) report_type: Optional[str] = Field(default=None)