Data Retention
All data retention settings are managed centrally in Settings → General Settings → Retention tab.
How it works:
Primentra uses a SQL Server Agent job to handle all data cleanup automatically. The job runs usp_Maintenance_Cleanup at a regular interval (default: every 60 seconds). Each run:
- Reads the configured retention period for each table from the
AppSettingsdatabase table - Calls the dedicated cleanup stored procedure for each table
- Deletes records older than the configured number of days
- Logs the result to the
SchedulerLogtable — but only when records were actually deleted. No-op runs (nothing to clean up) are silent.
The DELETE operations are cheap no-ops when there is nothing to purge, so the frequent interval does not cause performance issues.
Managed tables:
| Table | Setting | Default | What gets deleted |
|---|---|---|---|
AuditLog | auditRetentionDays | 90 days | All change history entries (who changed what, when) older than the cutoff |
ApprovalRequests | approvalRetentionDays | 365 days | Resolved approval requests (approved, rejected, returned, cancelled). Pending requests are never deleted. Cascade deletes ApprovalRows and ApprovalReviews |
ErrorLog | errorLogRetentionDays | 30 days | Database error log entries (HTTP errors, server events, slow requests). The file-based system log (errorlog.txt) is not affected |
StagingImport | stagingRetentionDays | 7 days | Processed staging import records. Pending imports (not yet processed) are never deleted |
SchedulerLog | schedulerLogRetentionDays | 30 days | Scheduler dispatch events (fired, completed, skipped, errors) |
Settings storage:
Retention values are stored in the AppSettings table in the database — not in a configuration file. This means:
- The SQL Server Agent job always reads the latest values directly from the database
- Changes take effect immediately after saving in the UI — no server restart required
- All settings are backed up with the database
Cleanup logging:
When usp_Maintenance_Cleanup deletes records, it writes one entry per table to SchedulerLog with:
EventType=cleanupEntityId=0(system-level operation, not entity-specific)Message= descriptive summary, e.g.[Audit Log] Cleaned 42 records (retention: 90 days). Everything before 2025-12-02 was removed.
You can view these entries in Settings → Log Viewer by filtering for the cleanup event type, or query them directly:
Cutoff banner:
Each retention card in the UI shows an orange warning banner with the exact cutoff date. For example, with 90-day audit retention and today = 2 March 2026, the banner shows: *"All entries before 2 December 2025 will be removed."* This updates live as you change the value.
SQL Server Agent job:
The cleanup is triggered by a SQL Server Agent job that calls usp_Maintenance_Cleanup. This job is created automatically during the Primentra installation — no manual setup required. You can still execute usp_Maintenance_Cleanup manually in SSMS at any time to trigger a one-time cleanup.