Bufdir Export
Data Entity
Description
Records each Bufdir compliance report export generated by an organization administrator from the Admin Web Portal. Captures the reporting period, export file reference, generation metadata, and download audit trail. Serves as the immutable export ledger for Norwegian government grant compliance.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key, globally unique export record identifier | PKrequiredunique |
organization_id |
uuid |
FK to organizations — the tenant that generated this export | required |
generated_by_user_id |
uuid |
FK to users — the Org Admin who triggered generation | required |
report_period_start |
datetime |
Start of the Bufdir reporting period (inclusive, UTC midnight) | required |
report_period_end |
datetime |
End of the Bufdir reporting period (inclusive, UTC end-of-day) | required |
status |
enum |
Lifecycle state of the export job | required |
export_format |
enum |
File format produced for Bufdir submission | required |
schema_version |
string |
Bufdir report schema version used at generation time (e.g. '2024-v2'). Preserved for audit so schema drift does not invalidate historical exports. | required |
activity_count |
integer |
Number of activity records included in the export snapshot | - |
file_path |
string |
Storage path or object key for the generated export file (cloud storage or file system) | - |
file_size_bytes |
integer |
Byte size of the generated export file | - |
file_checksum |
string |
SHA-256 hex digest of the export file for integrity verification on download | - |
download_count |
integer |
Number of times this export has been downloaded — incremented on each successful download | required |
last_downloaded_at |
datetime |
Timestamp of the most recent successful download, null if never downloaded | - |
last_downloaded_by_user_id |
uuid |
FK to users — identity of the last person to download this export | - |
error_message |
text |
Human-readable error detail when status=failed. Null for successful exports. | - |
metadata |
json |
Supplementary generation metadata: filter parameters applied, data source snapshot timestamp, Bufdir grant reference codes, and any org-specific report configuration values | - |
generated_at |
datetime |
Timestamp when export generation was triggered (not when it completed) | required |
completed_at |
datetime |
Timestamp when the export file was successfully written and status transitioned to completed | - |
created_at |
datetime |
Row creation timestamp | required |
updated_at |
datetime |
Row last-update timestamp | required |
Database Indexes
idx_bufdir_exports_organization_id
Columns: organization_id
idx_bufdir_exports_organization_period
Columns: organization_id, report_period_start, report_period_end
idx_bufdir_exports_generated_by
Columns: generated_by_user_id
idx_bufdir_exports_status
Columns: status
idx_bufdir_exports_generated_at
Columns: generated_at
Validation Rules
period_start_before_end
error
Validation failed
valid_export_format
error
Validation failed
schema_version_non_empty
error
Validation failed
file_checksum_format
error
Validation failed
file_path_required_on_complete
error
Validation failed
activity_count_non_negative
error
Validation failed
Business Rules
org_admin_only_access
Only users with an Org Admin or Global Admin role within the organization may create or download Bufdir exports. Coordinators and Peer Mentors have no access to this entity.
period_must_not_be_future
The report_period_end must not be in the future at the time of export generation. Bufdir reports are retrospective.
completed_export_is_immutable
Once status transitions to 'completed', file_path, file_checksum, file_size_bytes, activity_count, and schema_version become immutable. Any regeneration creates a new export record rather than overwriting the existing one.
download_audit_required
Every file download must increment download_count, update last_downloaded_at and last_downloaded_by_user_id, and write an entry to audit_logs before the file stream is returned. A download without a successful audit write must be aborted.
tenant_isolation
An organization may only read and download its own exports. Cross-tenant access is prohibited even for Global Admins unless explicit support access has been granted and is within its time-bound window.
failed_export_requires_error_message
When status transitions to 'failed', error_message must be populated with a non-empty diagnostic string.