feat(11-01): create sites table migration, model, and schemas

- Add migration 030 with sites table, RLS policy, and device site_id FK
- Add Site SQLAlchemy model with tenant isolation
- Add site_id nullable FK and relationship to Device model
- Add sites relationship to Tenant model
- Register Site in models __init__.py
- Add SiteCreate, SiteUpdate, SiteResponse, SiteListResponse schemas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-18 21:37:08 -05:00
parent 0693e0898b
commit f7e678532c
6 changed files with 229 additions and 0 deletions

View File

@@ -52,6 +52,9 @@ class Tenant(Base):
device_tags: Mapped[list["DeviceTag"]] = relationship(
"DeviceTag", back_populates="tenant", passive_deletes=True
) # type: ignore[name-defined]
sites: Mapped[list["Site"]] = relationship(
"Site", back_populates="tenant", cascade="all, delete-orphan"
) # type: ignore[name-defined]
def __repr__(self) -> str:
return f"<Tenant id={self.id} name={self.name!r}>"