2017-02-26 04:14:18 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Console\Commands;
|
|
|
|
|
2020-11-21 19:17:45 -05:00
|
|
|
use BookStack\Entities\Models\PageRevision;
|
2017-02-26 04:14:18 -05:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2023-05-24 08:21:46 -04:00
|
|
|
class ClearRevisionsCommand extends Command
|
2017-02-26 04:14:18 -05:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'bookstack:clear-revisions
|
|
|
|
{--a|all : Include active update drafts in deletion}
|
|
|
|
';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Clear page revisions';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
2023-05-24 07:59:50 -04:00
|
|
|
public function handle(): int
|
2017-02-26 04:14:18 -05:00
|
|
|
{
|
|
|
|
$deleteTypes = $this->option('all') ? ['version', 'update_draft'] : ['version'];
|
2023-05-24 07:59:50 -04:00
|
|
|
PageRevision::query()->whereIn('type', $deleteTypes)->delete();
|
2017-02-26 04:14:18 -05:00
|
|
|
$this->comment('Revisions deleted');
|
2023-05-24 07:59:50 -04:00
|
|
|
return 0;
|
2017-02-26 04:14:18 -05:00
|
|
|
}
|
|
|
|
}
|