23 lines
650 B
Python

from typing import Optional, TYPE_CHECKING
from uuid import UUID, uuid4
from sqlmodel import Field, Relationship, SQLModel
if TYPE_CHECKING:
from backend.app.models.owner import Owner
class House(SQLModel, table=True):
id: UUID = Field(primary_key=True, default_factory=uuid4)
address: str = Field()
city: str = Field()
country: str = Field()
price: float = Field()
description: str = Field()
owner_user_id: UUID = Field(foreign_key="owner.user_id")
square_feet: float = Field()
bedrooms: int = Field()
bathrooms: float = Field()
owner: Optional["Owner"] = Relationship(back_populates="houses")