← Back to docs

irclog-rollback

Language: EN | EN | SV

IRC Log Rollback System

Overview

The rollback system provides a safety mechanism to undo accidental production imports. If logfiles are imported to production by mistake, you can now easily remove them without manual database surgery.

Key Features

1. Approval Tracking

2. Batch Linking

3. Rollback Process

The rollback system provides a multi-step process:

  1. Confirm - Review job details and provide a rollback reason
  2. Execute - Permanently delete all events from production matching this batch
  3. Audit - Track all rollbacks in the audit history

4. Audit Trail

All rollback actions are permanently recorded:

Using the Rollback Feature

Step 1: Identify Problem Job

Go to Admin → IRC Memory Lane and find the job that needs to be rolled back.

Step 2: Click Rollback

From the job detail page, if the job is completed (status = "done"), you'll see a "🔄 Rollback from Production" button.

Step 3: Confirm Rollback

Step 4: Verify

The page will show:

Viewing Rollback History

To see all past rollbacks:

  1. Go to Admin → IRC Memory Lane
  2. Click "Rollback History" button
  3. View the complete audit trail of all rollbacks

Each entry shows:

Database Changes

Two new migrations add rollback tracking:

Migration: 2026_03_01_000000_add_rollback_tracking_to_batches.php

Adds columns to both import_batches and irclog_import_jobs tables:

Migration: 2026_03_01_000001_add_irclog_permissions.php

Adds two new permissions:

API Endpoints

GET /admin/irclog/{jobId}/rollback

Show confirmation page for rollback

POST /admin/irclog/{jobId}/rollback

Execute the rollback

Request body:

{
  "reason": "Accidental import of test data"
}

GET /admin/irclog/rollback/history

View rollback audit trail

GET /admin/irclog/api/rollback/{jobId}

Get rollback info for a job (API response)

Response:

{
  "rolled_back": true,
  "rolled_back_at": "2026-03-01T15:30:00Z",
  "rolled_back_by": "Thomas Tornevall",
  "reason": "Accidental import"
}

Service: ImportRollbackService

The App\Services\IrcLog\ImportRollbackService class handles all rollback logic:

// Rollback a job
$service = app(ImportRollbackService::class);
$result = $service->rollbackJob($jobId, $user, 'Reason...');

// Check if successful
if ($result['success']) {
    echo "Rolled back! " . $result['message'];
    echo "Deleted " . $result['stats']['events_deleted'] . " events";
}

// Get rollback info
$info = $service->getRollbackInfo($jobId);
if ($info) {
    echo "Rolled back by: " . $info['rolled_back_by'];
}

// Get all rollbacks
$history = $service->getRolledBackBatches(100);

Important Notes

⚠️ Permanent Deletion: Rollback permanently deletes events from production. Make sure you have backups before proceeding.

⚠️ Referential Integrity: If other systems reference the deleted events, they may break. Use sparingly.

Audit Trail: All rollbacks are traceable and cannot be undone. They are recorded in the database permanently.

Permission Control: Only users with irclog.manage permission can rollback.

Example Scenario

  1. You upload a 10,000 event log file
  2. Dry-run shows 10,000 events to import
  3. You approve and merge to production
  4. An hour later, you realize it was a test file that shouldn't be in production
  5. Go to IRC Log Admin → find the job → click "Rollback from Production"
  6. Provide reason: "Test data accidentally imported"
  7. Confirm by checking the checkbox
  8. Click "Execute Rollback" - all 10,000 events are deleted
  9. Go to "Rollback History" to verify it's recorded

Troubleshooting

"No production batch found for this job"

"This job has already been rolled back"

Rollback seems to hang or timeout

Future Enhancements

Potential improvements to consider: