1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Console\Commands;
7
8use App\Libraries\Search\ScoreSearch;
9use Illuminate\Console\Command;
10
11class EsIndexScoresSetSchema extends Command
12{
13 /**
14 * The name and signature of the console command.
15 *
16 * @var string
17 */
18 protected $signature = 'es:index-scores:set-schema
19 {--schema= : Schema version to be set}';
20
21 /**
22 * The console command description.
23 *
24 * @var string
25 */
26 protected $description = 'Set schema version of score index.';
27
28 /**
29 * Execute the console command.
30 *
31 * @return mixed
32 */
33 public function handle()
34 {
35 $schema = presence($this->option('schema'));
36
37 if ($schema === null) {
38 return $this->error('Index schema must be specified');
39 }
40
41 (new ScoreSearch())->setSchema($schema);
42
43 $this->info("Set score index schema version to {$schema}");
44 }
45}