Organization Label
Data Entity
Description
Organization-specific terminology overrides replacing default labels throughout the app interface, enabling each member organization to use its own cultural vocabulary. For example, different organizations use different terms for 'peer mentor' and related concepts.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Unique identifier for the label override record. Generated server-side via gen_random_uuid(). | PKrequiredunique |
organization_id |
uuid |
Foreign key referencing the organization that owns this label override. All label queries are scoped to a single organization. | required |
label_key |
string |
The canonical label key identifying which UI string this record overrides. Must match a value defined in the LabelKey constants (e.g., 'role.peer_mentor', 'role.coordinator', 'org_unit.local_association', 'activity.summary_label'). Dot-namespaced by domain. | required |
label_value |
string |
The organization-specific display string that replaces the default English/Norwegian label for the given key in all UI surfaces for this organization. | required |
updated_at |
datetime |
Timestamp of the most recent update to this label override. Set on insert and updated on every modification via a Supabase database trigger. | required |
updated_by |
uuid |
Foreign key referencing the user (admin) who last created or modified this label override. Used for audit trail in admin views. | required |
created_at |
datetime |
Timestamp when the label override was first created. Immutable after insert. | required |
Database Indexes
idx_org_labels_org_key_unique
Columns: organization_id, label_key
idx_org_labels_organization_id
Columns: organization_id
idx_org_labels_updated_at
Columns: organization_id, updated_at
Validation Rules
label_value_not_empty
error
Validation failed
label_value_max_length_200
error
Validation failed
label_key_format
error
Validation failed
organization_id_exists
error
Validation failed
updated_by_references_valid_user
error
Validation failed
label_key_in_registered_enum
error
Validation failed
no_special_chars_in_label_value
warning
Validation failed
Business Rules
one_label_per_key_per_org
Each organization may define at most one override value per label_key. The composite unique index on (organization_id, label_key) enforces this at the database level. Upsert semantics (INSERT ... ON CONFLICT DO UPDATE) are used by the batch save API.
admin_write_only
Only users with the 'admin' or 'global_admin' role scoped to the target organization may create, update, or delete label overrides. Coordinators and peer mentors have read-only access via RLS policies.
label_key_must_be_registered
The label_key value must correspond to an entry in the LabelKey constants defined in label-keys-constants. Unrecognized keys are rejected to prevent orphaned configuration data that no UI component would ever resolve.
cache_invalidation_on_update
Any write (create, update, delete) to org_labels for a given organization_id must invalidate the in-memory Riverpod label cache for that organization. The next call to Labels Service will re-fetch from Supabase, ensuring all UI surfaces reflect the latest terminology within the same session.
organization_scoped_rls
Supabase RLS policies enforce that users can only read org_labels rows belonging to organizations they are members of (via user_organization_memberships). Cross-organization label reads are prohibited, ensuring terminology isolation between organizations.
fallback_to_default_on_missing_key
When no org_labels row exists for a given (organization_id, label_key) pair, the Labels Service must return the default value defined in label-keys-constants rather than null or an empty string. This ensures the app is always legible even for organizations that have not configured any terminology overrides.
updated_by_must_be_active_admin
The updated_by field must reference a user with an active admin role in the organization at the time of write. Deactivated admin users cannot be recorded as the modifier.
CRUD Operations
Storage Configuration
Entity Relationships
Each organization defines its own terminology label overrides for all configurable text keys in the app