derived PK: id 12 required 1 unique

Description

User-defined report configurations allowing org admins to define tailored report queries beyond standard Bufdir and team reports, specifying filters, groupings, and output formats for custom analytics.

22
Attributes
4
Indexes
5
Validation Rules
9
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Foreign key to organizations — report belongs to this tenant
required
created_by_user_id uuid User (org admin) who created the report definition
required
name string Human-readable report name
required
description text Optional description of report purpose
-
report_type enum Category of data the report queries
required
filters json JSON object defining filter criteria (date ranges, roles, areas, organizations)
-
groupings json JSON array defining how results are grouped (by user, area, date, organization)
-
columns json JSON array of column definitions to include in output
required
output_format enum File format for export
required
date_range_type enum Whether the report uses a fixed or rolling date window
required
date_from datetime Start of fixed date range (null for rolling ranges)
-
date_to datetime End of fixed date range (null for rolling ranges)
-
is_scheduled boolean Whether this report runs on a schedule
required
schedule_cron string Cron expression for scheduled execution (null if not scheduled)
-
last_run_at datetime Timestamp of most recent execution
-
last_run_status enum Result of most recent execution
-
last_run_row_count integer Number of rows returned in the last execution
-
last_output_file_url string Signed URL or file path of the most recent export file
-
is_active boolean Soft-delete / disable flag
required
created_at datetime Record creation timestamp
required
updated_at datetime Last modification timestamp
required

Database Indexes

idx_custom_reports_organization_id
btree

Columns: organization_id

idx_custom_reports_created_by
btree

Columns: created_by_user_id

idx_custom_reports_org_active
btree

Columns: organization_id, is_active

idx_custom_reports_scheduled
btree

Columns: is_scheduled, is_active

Validation Rules

name_not_empty error

Validation failed

columns_not_empty error

Validation failed

valid_output_format error

Validation failed

valid_cron_expression error

Validation failed

filters_valid_json error

Validation failed

Business Rules

org_scoped_access
always

A custom report is always scoped to one organization. Users from org A cannot read or execute reports belonging to org B.

Enforced by: CustomReportService
org_admin_only_create
on_create

Only users with the Organization Admin or Global Admin role may create, edit, or delete custom report definitions.

Enforced by: CustomReportService
fixed_range_requires_dates
on_create

When date_range_type is 'fixed', both date_from and date_to must be provided and date_from must be before date_to.

schedule_requires_cron
on_create

If is_scheduled is true, schedule_cron must be a valid cron expression.

Enforced by: CustomReportService
bufdir_excluded_from_custom_reports
always

Custom reports must not duplicate Bufdir compliance data — they are for supplementary analytics only. Bufdir export is handled exclusively by BufdirExportService.

Enforced by: CustomReportService
test_org_excluded_from_output
always

Data belonging to Norse Test Organization must not appear in any custom report output, consistent with the rule that test data is excluded from all external reporting.

Enforced by: CustomReportService

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage