core PK: id 10 required 1 unique

Description

A planned group activity or gathering organized by peer mentors or coordinators within an organization. Events have a defined date, time, location, and optional capacity limit. Contacts and peer mentors can sign up to attend. Events are distinct from individual activity logs — they represent scheduled group sessions rather than one-on-one interactions.

17
Attributes
5
Indexes
10
Validation Rules
22
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key. Immutable unique identifier for the event.
PKrequiredunique
organization_id uuid Foreign key to organizations. Events are tenant-scoped — no event is visible outside its organization.
required
created_by_user_id uuid Foreign key to users. The peer mentor or coordinator who created the event.
required
title string Short display name for the event (e.g. 'NHF Autumn Gathering Oslo'). Shown in event cards and listings.
required
description text Free-text description of the event — agenda, what to bring, accessibility notes, etc.
-
location string Physical address or venue name. May be 'Online' for virtual events.
-
event_date datetime Date and start time of the event in UTC. Combined date+time field (not split) to avoid timezone ambiguity in mobile display.
required
duration_minutes integer Expected duration of the event in minutes. Used to compute end time and for Bufdir reporting.
required
capacity integer Maximum number of registrations allowed. NULL means unlimited. When capacity is reached, sign-up is closed.
-
registration_deadline datetime UTC timestamp after which new sign-ups are rejected. Must be before event_date. NULL means sign-ups are accepted until the event starts.
-
status enum Lifecycle state of the event. Controls visibility and allowed operations.
required
is_public boolean When true, the event is visible to all users in the organization. When false, only the creator and coordinators can see it.
required
cancellation_reason text Required when status is set to 'cancelled'. Stored for audit trail and to notify registered participants.
-
cancelled_at datetime UTC timestamp of when the event was cancelled. Set automatically when status transitions to 'cancelled'.
-
completed_at datetime UTC timestamp of when the event was marked as completed. Set automatically or manually by the creator/coordinator.
-
created_at datetime UTC timestamp of record creation. Immutable after insert.
required
updated_at datetime UTC timestamp of last modification. Auto-updated on every write.
required

Database Indexes

idx_events_organization_id
btree

Columns: organization_id

idx_events_created_by_user_id
btree

Columns: created_by_user_id

idx_events_event_date
btree

Columns: event_date

idx_events_organization_status_date
btree

Columns: organization_id, status, event_date

idx_events_status
btree

Columns: status

Validation Rules

title_required_and_bounded error

Validation failed

event_date_must_be_future_on_create error

Validation failed

duration_positive_integer error

Validation failed

registration_deadline_before_event_date error

Validation failed

capacity_positive_if_set error

Validation failed

cancellation_reason_required_on_cancel error

Validation failed

organization_id_immutable error

Validation failed

location_max_length error

Validation failed

description_max_length error

Validation failed

capacity_not_reducible_below_active_registrations error

Validation failed

Business Rules

tenant_isolation
always

An event is always scoped to a single organization. Events from one organization are never returned in queries for another organization. All reads and writes must include organization_id as a filter.

coordinator_or_peer_mentor_can_create
on_create

Only users with the Coordinator or Peer Mentor role (within the event's organization) may create events. Global Admins and Org Admins acting on behalf of an org may also create. Unauthenticated users are rejected.

only_creator_or_coordinator_can_edit
on_update

Only the user who created the event, a Coordinator in the same organization, or an Org Admin may update or cancel the event.

no_edits_after_completion
on_update

Once an event transitions to 'completed' status, all fields except cancellation_reason are immutable. Completed events serve as historical records for Bufdir reporting.

cancellation_closes_registrations
on_update

When an event is cancelled, all pending event_registrations for that event are automatically set to 'cancelled' status. Notification scenarios for cancellation are triggered.

capacity_enforcement
always

When capacity is set, new sign-ups (event_registrations) are rejected once the count of active registrations reaches capacity. The event's registration status changes to 'full' for display purposes.

registration_deadline_enforcement
always

When registration_deadline is set and the current time is past that deadline, new sign-up requests are rejected with a clear error message. Event listing shows deadline prominently.

soft_delete_not_hard_delete
on_delete

Events are never hard-deleted from the database. Deletion operations transition status to 'cancelled' with a system-generated cancellation reason. This preserves the audit trail and Bufdir reporting data.

draft_not_visible_to_participants
always

Events in 'draft' status are only visible to their creator and coordinators. They do not appear in the public event listing for peer mentors or contacts.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage