3 namespace BookStack\Console\Commands;
5 use BookStack\Entities\Models\PageRevision;
6 use Illuminate\Console\Command;
8 class ClearRevisionsCommand extends Command
11 * The name and signature of the console command.
15 protected $signature = 'bookstack:clear-revisions
16 {--a|all : Include active update drafts in deletion}
20 * The console command description.
24 protected $description = 'Clear page revisions';
27 * Execute the console command.
29 public function handle(): int
31 $deleteTypes = $this->option('all') ? ['version', 'update_draft'] : ['version'];
32 PageRevision::query()->whereIn('type', $deleteTypes)->delete();
33 $this->comment('Revisions deleted');