Maintenance Requests
Maintenance requests targeting exactly one of a device or a part
| Column Name | Data Type | Constraints |
|---|---|---|
| id | bigint | NOT NULL |
| device_id | bigint | FK -> devices |
| part_id | bigint | FK -> parts |
| defect_timestamp | timestamp with time zone | NOT NULL |
| creator_user_id | uuid | FK -> users |
| created_at | timestamp with time zone | DEFAULT now() NOT NULL |
| description | text | NOT NULL |
| image | text | |
| remediation_notes | text | |
| remediation_completed_at | timestamp with time zone | |
| remediation_completed_user_id | uuid | FK -> users |
| updated_by_user_id | uuid | FK -> users |
| updated_at | timestamp with time zone | |
| is_serviceable | boolean | DEFAULT true NOT NULL |
Exactly one of device_id or part_id is set (maintenance_requests_exactly_one_target).
Security Policies (RLS)
RLS enabled. Scope: Access resolved via maintenance_request_access from the target's device/part herd.
| Operation | has_herd_ability ability key | Other paths |
|---|---|---|
| SELECT | maintenance_requests.read | Target device API key, or approved gateway in the same herd |
| INSERT | maintenance_requests.write | Target device API key, or approved gateway in the same herd |
| UPDATE | maintenance_requests.write | Target device API key, or approved gateway in the same herd |
| DELETE | maintenance_requests.write | Target device API key, or approved gateway in the same herd |
Platform superadmin: FOR ALL bypass where defined.