the browser-facing portion of osu!
at master 2.5 kB view raw
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 Illuminate\Database\Console\Migrations\FreshCommand; 9use Symfony\Component\Console\Input\InputOption; 10 11class MigrateFreshAllCommand extends FreshCommand 12{ 13 public function handle() 14 { 15 if (!$this->confirmToProceed()) { 16 return 1; 17 } 18 19 $connections = $GLOBALS['cfg']['database']['connections']; 20 21 $this->warn('This will drop tables in the following databases:'); 22 23 foreach ($connections as $name => $config) { 24 $this->warn("{$name} => {$config['database']}"); 25 } 26 27 $continue = $this->option('no-interaction') || $this->confirm('continue?', true); 28 if (!$continue) { 29 $this->error('User aborted!'); 30 return 1; 31 } 32 33 foreach (array_keys($connections) as $database) { 34 $this->warn($database); 35 $this->call('db:wipe', [ 36 '--database' => $database, 37 '--drop-views' => true, 38 ]); 39 } 40 41 $this->info('Dropped all tables successfully.'); 42 43 $this->call('migrate', [ 44 '--path' => $this->input->getOption('path'), 45 ]); 46 47 $this->info('Setup elasticsearch indices.'); 48 49 $this->call('es:index-documents', [ 50 '--cleanup' => true, 51 '--no-interaction' => $this->option('no-interaction'), 52 ]); 53 54 $this->call('es:index-wiki', [ 55 '--cleanup' => true, 56 '--create-only' => true, 57 '--no-interaction' => $this->option('no-interaction'), 58 ]); 59 60 $this->call('es:create-search-blacklist'); 61 62 if ($this->needsSeeding()) { 63 $this->runSeeder(null); 64 } 65 66 return 0; 67 } 68 69 /** 70 * Get the console command options. 71 * 72 * @return array 73 */ 74 protected function getOptions() 75 { 76 return [ 77 ['force', null, InputOption::VALUE_NONE, 'This option is ignored.'], 78 ['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'], 79 ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], 80 ['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], 81 ]; 82 } 83}