core PK: id 11 required 1 unique

Description

Structured events created by peer mentors and coordinators within an organization. Events have a defined time, location, and capacity, and support participant sign-ups. Used for group meetings, training sessions, social gatherings, and career workshops. Linked to the Event Management area (MVP).

18
Attributes
6
Indexes
7
Validation Rules
15
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key. Client-generated UUID to support offline-first creation via the mutation outbox.
PKrequiredunique
organization_id uuid Foreign key to organizations. Enforces tenant isolation — events are scoped to a single organization.
required
created_by_user_id uuid Foreign key to users. The peer mentor or coordinator who created the event. Used for ownership checks and audit.
required
title string Human-readable name for the event. Displayed on the events list and detail screens.
required
description text Optional free-text description of the event's purpose, agenda, or other details.
-
event_type enum Categorizes the event for filtering, statistics, and Bufdir reporting alignment.
required
start_datetime datetime UTC timestamp for when the event begins. Stored as timezone-aware timestamp; displayed in the user's local timezone on device.
required
end_datetime datetime UTC timestamp for when the event ends. Must be strictly after start_datetime.
-
duration_minutes integer Explicit duration in minutes. When end_datetime is absent, this field defines event length. Defaults to 60 if neither end_datetime nor duration_minutes is set.
-
location string Human-readable location string (address, venue name, or video link). Not geocoded at MVP.
-
location_type enum Indicates how the event is hosted, used for display and accessibility planning.
required
max_participants integer Optional cap on the number of participants who can sign up. NULL means unlimited. Enforced at sign-up time by event-sign-up-service.
-
is_public boolean When true, all users within the organization can see and sign up for the event. When false, only explicitly invited users or the creator can see it.
required
status enum Lifecycle state of the event. Controls visibility and editability. Draft events are not visible to other users.
required
cancellation_reason text Optional reason provided when status is set to cancelled. Surfaced on the event detail screen.
-
created_at datetime UTC timestamp of record creation. Set server-side on insert.
required
updated_at datetime UTC timestamp of last update. Maintained by a database trigger or ORM hook.
required
deleted_at datetime Soft-delete timestamp. NULL means active. Non-null means logically deleted. All queries filter WHERE deleted_at IS NULL by default.
-

Database Indexes

idx_events_organization_id
btree

Columns: organization_id

idx_events_created_by_user_id
btree

Columns: created_by_user_id

idx_events_start_datetime
btree

Columns: start_datetime

idx_events_org_start
btree

Columns: organization_id, start_datetime

idx_events_org_status
btree

Columns: organization_id, status

idx_events_deleted_at
btree

Columns: deleted_at

Validation Rules

title_required_nonempty error

Validation failed

start_datetime_not_in_past error

Validation failed

end_after_start error

Validation failed

duration_positive error

Validation failed

max_participants_positive error

Validation failed

cancellation_reason_on_cancel warning

Validation failed

valid_organization_membership error

Validation failed

Business Rules

tenant_isolation
always

Every event must belong to exactly one organization. All reads and writes are scoped by organization_id derived from the authenticated user's session. Cross-organization event access is forbidden.

creator_ownership
on_update

Peer mentors may only edit or soft-delete events they created (created_by_user_id matches their user ID). Coordinators may edit or cancel any event within their organization.

no_reopen_cancelled
on_update

Once an event's status is set to 'cancelled', it cannot be transitioned back to 'published' or 'draft'. A new event must be created instead.

Enforced by: Event Service
auto_complete_past_events
on_update

Events whose end_datetime (or start_datetime + duration_minutes) has passed and whose status is 'published' are transitioned to 'completed' by a background job or lazily on next read.

Enforced by: Event Service
capacity_enforcement
on_create

When max_participants is set, sign-ups are rejected once event_participants count equals max_participants. Race conditions handled via SELECT FOR UPDATE in the sign-up transaction.

Enforced by: Event Sign-up Service
audit_on_cancellation
on_update

Cancelling an event writes an audit log entry including the cancellation_reason and the acting user's ID, for Bufdir compliance and organization oversight.

notify_participants_on_cancel
on_update

When an event's status changes to 'cancelled', all signed-up participants receive a push notification (and email/SMS if configured) informing them of the cancellation.

module_toggle_gate
always

Event creation, listing, and sign-up endpoints are only accessible when the 'event-management' module is enabled for the user's organization. Disabled module returns 403.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage