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:
@@ -101,6 +101,13 @@ class Device(Base):
|
||||
tag_assignments: Mapped[list["DeviceTagAssignment"]] = relationship(
|
||||
"DeviceTagAssignment", back_populates="device", cascade="all, delete-orphan"
|
||||
)
|
||||
site_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
UUID(as_uuid=True),
|
||||
ForeignKey("sites.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
site: Mapped["Site"] = relationship("Site", back_populates="devices") # type: ignore[name-defined]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Device id={self.id} hostname={self.hostname!r} tenant_id={self.tenant_id}>"
|
||||
|
||||
Reference in New Issue
Block a user