Adventure Labs Logo
Scout Docs

Users_roles_per_herd

Table for storing user role assignments per herd with role-based access control

Column NameData TypeConstraints
idbigintNOT NULL
inserted_attimestamp with time zoneDEFAULT timezone('utc'::text, now()) NOT NULL
user_iduuidNOT NULL
herd_idbigintNOT NULL
herd_role_idbigintNOT NULL, FK herd_roles
lifecyclepublic.entity_lifecycle (active, retired, deleted)DEFAULT active NOT NULL
lifecycle_changed_attimestamp with time zoneDEFAULT timezone('utc'::text, now()) NOT NULL
lifecycle_changed_byuuid
lifecycle_reasontext

Unique on (user_id, herd_id). Only lifecycle = active rows grant abilities via has_herd_ability; users.lifecycle must also be active.

Security Policies (RLS)

RLS enabled. Herd scope: Herd from users_roles_per_herd.herd_id.

Operationhas_herd_ability ability keyOther paths
SELECTusers_roles_per_herd.read—
INSERTusers_roles_per_herd.write—
UPDATEusers_roles_per_herd.write—
DELETEusers_roles_per_herd.write—

Platform superadmin: FOR ALL bypass where defined.

Losing active membership revokes pending invitations sent by that user for that herd. RPCs leave_herd_for_current_user / remove_user_from_herd_for_admin also require users_roles_per_herd.write when removing the last holder.

On this page