the browser-facing portion of osu!
at master 875 B 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 App\Models\Beatmap; 9use Illuminate\Console\Command; 10 11class BeatmapsMigrateOwners extends Command 12{ 13 protected $signature = 'beatmaps:migrate-owners'; 14 15 protected $description = 'Migrates beatmap owners to new table.'; 16 17 public function handle() 18 { 19 $progress = $this->output->createProgressBar(); 20 21 Beatmap::chunkById(1000, function ($beatmaps) use ($progress) { 22 foreach ($beatmaps as $beatmap) { 23 $beatmap->beatmapOwners()->firstOrCreate(['user_id' => $beatmap->user_id]); 24 $progress->advance(); 25 } 26 }); 27 28 $progress->finish(); 29 $this->line(''); 30 } 31}