Herd media usage
Point-in-time snapshots of stored media bytes for a herd
| Column Name | Data Type | Constraints |
|---|---|---|
| id | bigint | NOT NULL |
| herd_id | bigint | NOT NULL, FK -> herds |
| storage_bytes | bigint | NOT NULL, >= 0 |
| inserted_at | timestamp with time zone | DEFAULT timezone('utc'::text, now()) NOT NULL |
Each row records stored bytes for devices currently in the herd, across the buckets listed by private.media_usage_bucket_ids(): events, event_thumbnails, event_proxies, artifacts, artifact_thumbnails, artifact_proxies, and embedding_thumbnails.
The migration creates one initial snapshot per herd. Event, artifact, and media-storage changes refresh affected herds; unchanged totals are not duplicated.
Changes broadcast on the private {herd_id}-herd_media_usage topic, which requires media.read.
Security Policies (RLS)
RLS enabled. Herd scope: herd_media_usage.herd_id.
| Operation | has_herd_ability ability key | Other paths |
|---|---|---|
| SELECT | media.read | Owning device API key in herd |
| INSERT | — | Platform superadmin |
| UPDATE | — | Platform superadmin |
| DELETE | — | Platform superadmin |
Platform superadmin: FOR ALL.