core PK: id 10 required 1 unique

Description

A saved template for activities that recur regularly (e.g., weekly group training sessions), used by coordinators during bulk proxy registration. Templates pre-fill the activity type, default duration, and other defaults so coordinators can register the same activity for multiple peer mentors at once with minimal effort.

11
Attributes
6
Indexes
6
Validation Rules
8
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Unique identifier for the recurring activity template, generated server-side as a UUID v4.
PKrequiredunique
name string Human-readable name for the template (e.g., 'Weekly group training session'), displayed in the template selector UI.
required
coordinator_id uuid Foreign key referencing the coordinator user who created and owns this template. Determines ownership and audit attribution.
required
organization_id uuid Foreign key referencing the organization (tenant) this template belongs to. Used for multi-tenancy data isolation via Supabase RLS.
required
organization_unit_id uuid Foreign key referencing the organizational unit (chapter/local association) this template is scoped to. Coordinators only see templates from their assigned units. Derived from the organization_unit relationship.
required
activity_type_id uuid Foreign key referencing the activity type that this template pre-fills. Must reference an active, non-deleted activity type within the same organization.
required
default_duration_minutes integer Pre-filled duration in minutes for activities created using this template. Corresponds to typical session length (e.g., 60 for a one-hour weekly session). Must be a positive integer.
required
description text Optional free-text description giving coordinators additional context about when and how to use this template. Not used in activity registration payload.
-
is_active boolean Soft-delete flag. When false, the template is hidden from coordinator selectors but preserved for audit and historical reference. Defaults to true on creation.
required
created_at datetime UTC timestamp of when the template was created. Set automatically by the database on insert.
required
updated_at datetime UTC timestamp of the last modification to the template. Updated automatically by a database trigger on any row update.
required

Database Indexes

idx_recurring_activity_template_pkey
btree unique

Columns: id

idx_recurring_activity_template_coordinator
btree

Columns: coordinator_id

idx_recurring_activity_template_org_unit
btree

Columns: organization_unit_id

idx_recurring_activity_template_org_unit_coordinator
btree

Columns: organization_unit_id, coordinator_id

idx_recurring_activity_template_activity_type
btree

Columns: activity_type_id

idx_recurring_activity_template_org_active
btree

Columns: organization_id, is_active

Validation Rules

name_non_empty error

Validation failed

name_non_empty_on_update error

Validation failed

default_duration_positive error

Validation failed

activity_type_belongs_to_organization error

Validation failed

organization_unit_within_coordinator_scope error

Validation failed

description_max_length error

Validation failed

Business Rules

chapter_scope_isolation
always

A recurring activity template is always scoped to exactly one organization unit (chapter). Coordinators may only read, create, update, or soft-delete templates belonging to organization units they are assigned to. This is enforced both at the service layer and via Supabase RLS policies that join unit_assignments.

activity_type_must_be_active
on_create

The referenced activity_type_id must point to an active (non-deactivated) activity type within the same organization at time of creation and update. If the referenced activity type is subsequently deactivated, existing templates referencing it are preserved but cannot be used to initiate new bulk registrations until a valid active type is selected.

coordinator_ownership
on_update

Only the creating coordinator or an organization admin may modify (update name, description, duration) or soft-delete a template. Peer mentors have no access to template management. Role enforcement is applied at the service layer before repository calls.

soft_delete_only
on_delete

Templates are never hard-deleted. Setting is_active = false hides the template from coordinator selectors while preserving the record for audit and historical bulk registration traceability. Hard deletes are blocked at the repository layer.

template_used_in_bulk_registration_only
always

Templates pre-fill activity data for bulk proxy registration flows only. They are not used to auto-submit activities — a coordinator must explicitly confirm before any activity records are created. This prevents accidental mass registration.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

organization_unit
incoming one_to_many

Recurring activity templates are scoped to a chapter so coordinators only see templates relevant to their operational unit

optional cascade delete