Herd_invitations
Pending and historical invitations to join a herd
| Column Name | Data Type | Constraints |
|---|---|---|
| id | bigint | NOT NULL |
| text | NOT NULL | |
| herd_id | bigint | NOT NULL |
| herd_role_id | bigint | NOT NULL, FK herd_roles |
| invited_by | uuid | NOT NULL |
| status | public.herd_invitation_status (pending, accepted, revoked, expired) | DEFAULT pending NOT NULL |
| created_at | timestamp with time zone | DEFAULT timezone('utc'::text, now()) NOT NULL |
| accepted_at | timestamp with time zone | |
| expires_at | timestamp with time zone |
At most one pending invitation per (email, herd_id). Created via create_herd_invitation; accepted via accept_herd_invitations_for_current_user. Neither the RPC nor a direct update may assign a role that grants users_roles_per_herd.write unless the caller already holds that ability in the herd.
Security Policies (RLS)
RLS enabled. Herd scope: Herd from herd_invitations.herd_id.
| Operation | has_herd_ability ability key | Other paths |
|---|---|---|
| SELECT | herd_invitations.read | Invitee: email = current_user_email() (no ability check) |
| INSERT | — | Via create_herd_invitation RPC (herd_invitations.write inside function) |
| UPDATE | herd_invitations.write | Changing herd_role_id to a role holding users_roles_per_herd.write requires the caller to hold it (herd_invitations_role_guard) |
| DELETE | — | No direct user DELETE policy |
Platform superadmin: FOR ALL bypass where defined.