diff --git a/app/Console/Commands/FixBulkAccessoryCheckinActionLogEntries.php b/app/Console/Commands/FixBulkAccessoryCheckinActionLogEntries.php index 096f8f9e6..694d8d3b3 100644 --- a/app/Console/Commands/FixBulkAccessoryCheckinActionLogEntries.php +++ b/app/Console/Commands/FixBulkAccessoryCheckinActionLogEntries.php @@ -14,7 +14,7 @@ class FixBulkAccessoryCheckinActionLogEntries extends Command * * @var string */ - protected $signature = 'snipeit:fix-bulk-accessory-action-log-entries {--dry-run : Run the sync process but don\'t update the database}'; + protected $signature = 'snipeit:fix-bulk-accessory-action-log-entries {--dry-run : Run the sync process but don\'t update the database} {--skip-backup : Skip pre-execution backup}'; /** * The console command description. @@ -24,15 +24,15 @@ class FixBulkAccessoryCheckinActionLogEntries extends Command protected $description = 'This script attempts to fix timestamps and missing created_by values for bulk checkin entries in the log table'; private bool $dryrun = false; + private bool $skipBackup = false; /** * Execute the console command. */ public function handle() { - if ($this->option('dry-run')) { - $this->dryrun = true; - } + $this->skipBackup = $this->option('skip-backup'); + $this->dryrun = $this->option('dry-run'); if ($this->dryrun) { $this->info('This is a DRY RUN - no changes will be saved.'); @@ -71,6 +71,11 @@ class FixBulkAccessoryCheckinActionLogEntries extends Command return 0; } + if (!$this->dryrun && !$this->skipBackup) { + $this->info('Backing up the database before making changes...'); + $this->call('snipeit:backup'); + } + if ($this->dryrun) { $this->newLine(); $this->info('DRY RUN. NOT ACTUALLY UPDATING LOGS.');