Activity Document
Data Entity
Description
Stores document attachments linked to activity records, enabling peer mentors to attach supporting files (invitations, Facebook screenshots, etc.) to activities for Bufdir audit trail purposes.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
activity_id |
uuid |
Foreign key to the parent activity record | required |
uploaded_by_user_id |
uuid |
Foreign key to the user who uploaded the document | required |
file_name |
string |
Original filename as uploaded by the user | required |
file_size_bytes |
integer |
Size of the file in bytes | required |
mime_type |
string |
MIME type of the uploaded file (e.g. image/jpeg, application/pdf) | required |
storage_key |
string |
Cloud storage object key used to retrieve the file from the file storage backend | requiredunique |
storage_bucket |
string |
Cloud storage bucket name where the file is stored | required |
document_type |
enum |
Categorization of the document for Bufdir audit and display purposes | required |
description |
text |
Optional user-provided description or note about the attachment | - |
checksum_sha256 |
string |
SHA-256 hash of the file content for integrity verification | required |
is_deleted |
boolean |
Soft-delete flag; documents are never hard-deleted for audit integrity | required |
created_at |
datetime |
Timestamp when the document was attached | required |
updated_at |
datetime |
Timestamp of last metadata update | required |
Database Indexes
idx_activity_documents_activity_id
Columns: activity_id
idx_activity_documents_uploaded_by_user_id
Columns: uploaded_by_user_id
idx_activity_documents_storage_key
Columns: storage_key
idx_activity_documents_activity_id_is_deleted
Columns: activity_id, is_deleted
idx_activity_documents_created_at
Columns: created_at
Validation Rules
allowed_mime_types
error
Validation failed
max_file_size
error
Validation failed
file_name_not_empty
error
Validation failed
checksum_integrity
error
Validation failed
storage_key_uniqueness
error
Validation failed
activity_id_references_existing_activity
error
Validation failed
Business Rules
document_requires_parent_activity
A document attachment can only exist if the parent activity exists. Deleting an activity cascades to soft-delete all its documents.
uploader_must_own_activity_or_be_coordinator
Only the peer mentor who owns the activity or a coordinator in the same organization may attach documents. Org admins may attach via admin portal review flow.
soft_delete_only
Documents are never physically deleted. The is_deleted flag is set to true to preserve Bufdir audit trail integrity. Physical removal from cloud storage is deferred to a scheduled retention policy process.
document_attachments_module_toggle
Document attachment functionality is only available when the document-attachments feature is enabled for the organization. Requests from organizations without this toggle must be rejected at the API layer.
max_documents_per_activity
An activity may have at most 10 non-deleted document attachments to prevent storage abuse.