Adventure Labs Logo
Scout Docs

Herd_roles

Per-herd role definitions and stable system names

Column NameData TypeConstraints
idbigintNOT NULL
herd_idbigintNOT NULL, FK herds
system_nametextNOT NULL, unique per herd
nametextNOT NULL
is_systembooleanDEFAULT false NOT NULL
inserted_attimestamptzNOT NULL

System roles (is_system = true) are seeded on herd creation by seed_herd_default_roles from Platform_default_roles (admin, editor, viewer unless the catalog has been changed). The herd creator is enrolled in the catalog's member-managing role. System roles mirror the catalog: renaming a catalog role, changing its template, or registering a new one is applied to every herd, and deleting a catalog role turns each herd's copy into an ordinary custom role (is_system = false) that keeps its abilities. Herd admins may create and shape non-system roles only; system roles cannot be inserted, changed, or deleted through RLS. When two accounts holding roles in the same herd are merged, the membership keeps the role with fewer abilities.

Security Policies (RLS)

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

Operationhas_herd_ability ability keyOther paths
SELECThas_herd_ability_any: users_roles_per_herd.read or users_roles_per_herd.write—
INSERTusers_roles_per_herd.writeis_system = false required
UPDATEusers_roles_per_herd.writeis_system = false required before and after
DELETEusers_roles_per_herd.writeis_system = false required

Platform superadmin: FOR ALL bypass where defined.

On this page