mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from sqlmodel import Field, SQLModel, Relationship
|
|
import uuid
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
from pydantic import EmailStr
|
|
from sqlalchemy import Column
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from etl.pdfReader.reportType import ReportType
|
|
|
|
class BaseModel(SQLModel):
|
|
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
|
|
|
class Buildings(BaseModel, table=True):
|
|
address: str
|
|
postcode: str
|
|
UPRN: str
|
|
landlord_id: str
|
|
domna_id: str
|
|
|
|
documents: List["Documents"] = Relationship(back_populates="building")
|
|
|
|
class Documents(BaseModel, table=True):
|
|
assessor_id: uuid.UUID = Field(
|
|
foreign_key="assessorinfo.id",
|
|
nullable=False
|
|
)
|
|
author: Optional["AssessorInfo"] = Relationship(back_populates="documents")
|
|
created_at: datetime
|
|
document_type: ReportType
|
|
|
|
building_id: uuid.UUID = Field(foreign_key="buildings.id", nullable=False)
|
|
building: Optional["Buildings"] = Relationship(back_populates="documents")
|
|
|
|
target_table: str
|
|
target_id: uuid.UUID
|
|
|
|
Documents.update_forward_refs()
|
|
|