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.
approved_by_user_id)approved_at)production_batch_id)The rollback system provides a multi-step process:
All rollback actions are permanently recorded:
Go to Admin → IRC Memory Lane and find the job that needs to be rolled back.
From the job detail page, if the job is completed (status = "done"), you'll see a "🔄 Rollback from Production" button.
The page will show:
To see all past rollbacks:
Each entry shows:
Two new migrations add rollback tracking:
2026_03_01_000000_add_rollback_tracking_to_batches.phpAdds columns to both import_batches and irclog_import_jobs tables:
approved_by_user_id - User who approved the jobapproved_at - Timestamp of approvalis_rolled_back - Whether this has been rolled backrolled_back_at - When the rollback occurredrolled_back_by_user_id - Who initiated the rollbackrollback_reason - Why it was rolled back2026_03_01_000001_add_irclog_permissions.phpAdds two new permissions:
irclog.manage - Can manage IRC logsirclog.rollback - Can rollback production imports/admin/irclog/{jobId}/rollbackShow confirmation page for rollback
/admin/irclog/{jobId}/rollbackExecute the rollback
Request body:
{
"reason": "Accidental import of test data"
}
/admin/irclog/rollback/historyView rollback audit trail
/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"
}
ImportRollbackServiceThe 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);
⚠️ 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.
"No production batch found for this job"
"This job has already been rolled back"
Rollback seems to hang or timeout
Potential improvements to consider: