Site Maintenance Schema
The site_maintenance schema owns facility care: inspection walkthroughs, preventive maintenance schedules, service completion history, work items, and inspection media.
Domain Models
site_maintenance.walkthroughs— Property inspection sessions capturing general notes, site condition, and linked media. Creator is pinned toauth.uid().site_maintenance.schedules— Recurring service intervals for specific site equipment or building systems (active,paused,cancelled).site_maintenance.service_completions— Append-only completion logs. Recording service advances the schedule'snext_due_at.site_maintenance.work_items— Identified maintenance issues requiring client decision (accept,defer,decline) and technician resolution.media.walkthrough_media— Photos and videos captured during walkthroughs, stored in object storage with metadata links.
Dual Access Model (Staff vs. Enterprise Client)
| Capability | Internal API (Staff) | Enterprise API (Client Portal) |
|---|---|---|
| Walkthroughs | Create, edit, and submit via internal FastAPI (site_maintenance_admin). |
Read-only views via enterprise_api.walkthroughs (scoped by site RLS). |
| Schedules | Create, pause, and record service completions via internal_api RPCs. |
Read upcoming maintenance via enterprise_api.maintenance_schedules. |
| Work Items | Create and triage repairs via internal tools. | Review and submit decisions via POST /sites/{id}/work-items/{id}/decision. |
| PDF Reports | Render verified walkthrough and completion summaries. | Download expiring signed PDFs via enterprise media routes. |
Media & Storage Architecture
Inspection media uses a two-phase upload protocol:
1. The client requests an upload intent (POST /sites/{id}/media/upload-intents), receiving a presigned S3/RustFS PUT URL.
2. After the object is uploaded, a storage webhook (/internal/media/object-created) verifies file size/MIME type and promotes the media record atomically in PostgreSQL.