Documentation
Getting Started
Installation
Data Grid
Approvals
Administration
Account & Security
Integration & Staging
Architecture
Documentation/Administration/System/Data Retention

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:

  1. Reads the configured retention period for each table from the AppSettings database table
  2. Calls the dedicated cleanup stored procedure for each table
  3. Deletes records older than the configured number of days
  4. Logs the result to the SchedulerLog table — 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:

TableSettingDefaultWhat gets deleted
AuditLogauditRetentionDays90 daysAll change history entries (who changed what, when) older than the cutoff
ApprovalRequestsapprovalRetentionDays365 daysResolved approval requests (approved, rejected, returned, cancelled). Pending requests are never deleted. Cascade deletes ApprovalRows and ApprovalReviews
ErrorLogerrorLogRetentionDays30 daysDatabase error log entries (HTTP errors, server events, slow requests). The file-based system log (errorlog.txt) is not affected
StagingImportstagingRetentionDays7 daysProcessed staging import records. Pending imports (not yet processed) are never deleted
SchedulerLogschedulerLogRetentionDays30 daysScheduler 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 = cleanup
  • EntityId = 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:

SELECT EventTime, Message
FROM   SchedulerLog
WHERE  EventType = 'cleanup'
ORDER BY EventTime DESC;

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.

Ready to get started?

Start managing your master data with Primentra today.

View Pricing