Skip to content

Commit 27ec81f

Browse files
authored
readme.md
1 parent b5ff293 commit 27ec81f

File tree

1 file changed

+16
-0
lines changed
  • Server-Side Components/Background Scripts/Automated Cleanup of Historical Records

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Purpose
2+
This script automates the cleanup of historical records (closed incidents older than 90 days) while preserving records linked to active change requests or tasks. This helps improve system performance and database maintenance.
3+
4+
## Use Case
5+
- Remove outdated incidents that are no longer required.
6+
- Prevent accidental deletion of records linked to other critical tables.
7+
- Can be extended to other tables like `problem`, `change_request`, etc.
8+
9+
## Script Details
10+
- **Table:** `incident`
11+
- **Filter Criteria:**
12+
- Closed incidents (`state = 7`)
13+
- Older than 90 days (`closed_at <= gs.daysAgo(90)`)
14+
- **Safety Checks:** Skips records linked to `change_request` or child `task` records.
15+
- **Execution:** Can be run as Background Script or Scheduled Script Execution.
16+
- **Logging:** Outputs skipped and deleted records count in system logs.

0 commit comments

Comments
 (0)