survey_permissions
Overview
A join table holding per-survey sharing permissions: the role a user has on a survey (view / edit).
Table Definition
| Logical name | Physical name | Column | Type | PK | Relation | Unique | Nullable | Default | Notes |
|---|---|---|---|---|---|---|---|---|---|
| Survey permission | survey_permissions | survey_id | uuid | โฏ | surveys:id (cascade) | ||||
| user_id | uuid | โฏ | users:id (cascade) | ||||||
| role_type | permission_role | โฏ | view / edit | ||||||
| created_at | timestamptz | now() |
Relations
- survey_id โ surveys.id (onDelete: cascade)
- user_id โ users.id (onDelete: cascade)
Indexes
- Composite primary key (survey_id, user_id, role_type)
Notes
- On survey creation, the creator automatically receives
editpermission - On survey duplication, all permissions of the source survey are carried over
- Permission updates go through the bulk update (
PUT /api/surveys/{surveyId}/permissions), which deletes all existing permissions and inserts the given ones - Administrators can access every survey even without a row in this table
- The composite key technically allows one user to hold both
viewandediton the same survey, but the UI treats one user as having exactly one role