Documentation
Use Primentra
Getting Started
Data Grid
Approvals
Set up
Modeling
Business Rules
Users & Roles
Sign-in & Security
Install and run
Installation
Administration
Integration & API
Architecture
Migrate from MDS
Migrating from MDS

Data Retention

On this page

Primentra deletes old log and workflow records for you. All six retention periods live on one tab.

Access: Settings › General Settings › Retention

The Retention tab with the audit and approval retention cards
The Retention tab with the audit and approval retention cards(click to enlarge)

The six managed tables

CardTableSettingDefaultWhat is deleted
Audit Log RetentionAuditLogauditRetentionDays90 daysChange history: who changed what, when, and the old and new values
Approval Data RetentionApprovalRequestsapprovalRetentionDays365 daysResolved approval requests. Cascades to ApprovalRows and ApprovalReviews
Error Log RetentionErrorLogerrorLogRetentionDays30 daysDatabase error entries. The file errorlog.txt is not touched
Staging Data RetentionStagingImportstagingRetentionDays7 daysProcessed staging records. Pending imports are never deleted
Scheduler Log RetentionSchedulerLogschedulerLogRetentionDays30 daysScheduler dispatch events: fired, completed, skipped, zombie releases, errors
AI Call Log RetentionAiCallLogaiCallLogRetentionDays90 daysLogged AI assist calls: time, purpose, entity, user, provider, model and tokens. The calls of today always stay

Every card carries the table name, a description, a number field from 1 to 9999 days, preset buttons, and an orange banner with the exact cutoff date. The banner updates live as you change the value.

Set a retention period

  1. Open Settings › General Settings › Retention.
  2. Type a number of days, or click a preset.
  3. Read the orange banner to confirm the cutoff date.
  4. Click Save settings.

Changes take effect at the next cleanup run. No restart is needed.

Approval data retention

Only requests in a terminal state are eligible:

  • approved — the changes were accepted and committed to live data
  • rejected — the changes were declined
  • sent_back — the request was returned to the submitter for revision
  • cancelled — the submitter withdrew the request

Pending requests are never deleted automatically. They still await a decision.

The cutoff is measured from the date the request was submitted, not from the date it was resolved.

This is the only card with a Never preset. Set it to 0 and cleanup is disabled — a blue panel reads Approval records are kept indefinitely instead of the orange cutoff banner.

AI call log retention

Every call of AI assist gets one row in AiCallLog. The row holds no record values, only the time, the purpose, the entity, the user, the provider, the model, the token counts and the outcome.

  • The default is 90 days. The lowest value is 1 day.
  • The calls of today (UTC) always stay. The daily call limit counts them, so a cleanup never resets the count of the day.
  • A value below 1 that reaches the database some other way counts as 1.
  • Log settings on the AI calls tab of the Log Viewer opens this card. See AI Call Log.

How cleanup runs

A SQL Server Agent job runs usp_Maintenance_Cleanup every 60 seconds. Each run:

  1. Reads the six retention values from the AppSettings table.
  2. Calls the cleanup procedure for each table: usp_AuditLog_Cleanup, usp_Approval_Cleanup, usp_ErrorLog_Cleanup, usp_SchedulerLog_Cleanup, usp_Import_CleanupStaging and usp_Ai_CleanupCallLog.
  3. Writes one SchedulerLog row per table — but only when records were actually deleted. Runs that delete nothing are silent.

The DELETE statements are cheap when there is nothing to purge, so the 60-second interval costs almost nothing.

Because the values live in AppSettings and not in a configuration file, the job always reads the current numbers, and the settings are included in a database backup.

Reading the cleanup log

A cleanup entry looks like this:

[Audit Log] Cleaned 42 records (retention: 90 days). Everything before 2025-12-02 was removed.

Filter for the cleanup event type in Settings › Logs, or query the table:

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

The job must exist

Without the SQL Server Agent job, none of these settings do anything — nothing is ever deleted.

Primentra checks for the job itself. Settings › General Settings › Database reports it after every setup run, and the Processing Schedule panel warns about it whenever a schedule is set to run by itself. You do not have to go looking.

To check by hand, connect as a sysadmin and run:

SELECT name, enabled FROM msdb.dbo.sysjobs WHERE name = 'Primentra_Scheduler';

No rows means it was not created. Run scripts\create-scheduler-agent-job.sql once as a sysadmin. Also confirm that the SQL Server Agent service is running and set to start automatically — the job cannot fire without it.

SQL Server Express has no SQL Server Agent at all. Use the Windows Task Scheduler alternative described in Staging Scheduler.

To purge once by hand, execute usp_Maintenance_Cleanup in SSMS at any time.