core PK: id 10 required 1 unique

Description

Represents a caregiver or next-of-kin associated with a contact. Stores relationship metadata and contact details for people who care for or are closely related to a contact receiving peer mentor support.

14
Attributes
4
Indexes
8
Validation Rules
10
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
contact_id uuid Foreign key to the contact this caregiver is associated with
required
full_name string Full name of the caregiver or next-of-kin
required
relationship enum Relationship of the caregiver to the contact
required
relationship_description string Free-text description of the relationship when 'other' is selected or additional context is needed
-
phone_number string Primary phone number for the caregiver
-
email string Email address of the caregiver
-
is_primary_contact boolean Whether this caregiver is the primary next-of-kin contact for the associated contact
required
is_emergency_contact boolean Whether this caregiver should be contacted in an emergency
required
notes text Additional notes about this caregiver or the caregiving arrangement
-
organization_id uuid Tenant scoping — the organization that owns this caregiver record
required
created_by uuid User ID of the peer mentor or coordinator who created this record
required
created_at datetime Timestamp when the caregiver record was created
required
updated_at datetime Timestamp when the caregiver record was last modified
required

Database Indexes

idx_caregivers_contact_id
btree

Columns: contact_id

idx_caregivers_organization_id
btree

Columns: organization_id

idx_caregivers_contact_primary
btree

Columns: contact_id, is_primary_contact

idx_caregivers_created_by
btree

Columns: created_by

Validation Rules

full_name_required error

Validation failed

full_name_on_update error

Validation failed

relationship_enum_valid error

Validation failed

relationship_description_required_for_other error

Validation failed

email_format_check error

Validation failed

email_format_on_update error

Validation failed

phone_format_check warning

Validation failed

contact_id_exists error

Validation failed

Business Rules

single_primary_contact_per_contact
on_create

Only one caregiver per contact may have is_primary_contact = true. Setting a new primary automatically demotes the previous one.

Enforced by: CaregiverService
single_primary_contact_on_update
on_update

When updating is_primary_contact to true, the service must clear the flag on any existing primary caregiver for the same contact.

Enforced by: CaregiverService
tenant_isolation
always

Caregiver records are scoped to an organization. A user may only read or modify caregiver records belonging to their own organization.

contact_must_belong_to_same_org
on_create

The contact referenced by contact_id must belong to the same organization_id as the caregiver record.

Enforced by: CaregiverService
offline_sync_support
always

Caregiver create/update/delete operations must be written to the mutation outbox when the device is offline and reconciled during background sync.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage