Devices
Table for storing device information including location, type, and configuration
| Column Name | Data Type | Constraints |
|---|---|---|
| id | bigint | NOT NULL |
| inserted_at | timestamp with time zone | DEFAULT timezone('utc'::text, now()) NOT NULL |
| created_by | uuid | NOT NULL |
| herd_id | bigint | NOT NULL |
| name | text | NOT NULL |
| description | text | NOT NULL |
| domain_name | text | |
| altitude | double precision | |
| heading | double precision | |
| location | extensions.geography(Point,4326) | |
| video_publisher_token | text | |
| video_subscriber_token | text | |
| device_type | public.device_type | DEFAULT 'unknown' NOT NULL |
| color | text |
Security Policies (RLS)
RLS enabled. Herd scope: Herd from devices.herd_id.
| Operation | has_herd_ability ability key | Other paths |
|---|---|---|
| SELECT | devices.read | Own device API key (id = key_uid()); herd device API keys |
| INSERT | devices.write | Device API keys in herd |
| UPDATE | devices.write | Device API keys in herd |
| DELETE | devices.write | Device API keys in herd |
Platform superadmin: FOR ALL bypass where defined.
API keys
load_api_keys(id_of_device) and load_api_keys_batch(device_ids) return a device's API keys and require devices.api_keys.read in the device's herd (admin-only by default), platform superadmin, or the service role; they are not executable signed out.