From eed205b7f91d54ff17312dbc632c865a58df0027 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 9 Aug 2019 10:54:42 +0800 Subject: [PATCH] Remove v4 migration commands --- app/Console/Commands/MigrateCloset.php | 66 --------------- app/Console/Commands/MigratePlayersTable.php | 84 -------------------- app/Console/Commands/RegressLikesField.php | 44 ---------- app/Console/Kernel.php | 3 - 4 files changed, 197 deletions(-) delete mode 100644 app/Console/Commands/MigrateCloset.php delete mode 100644 app/Console/Commands/MigratePlayersTable.php delete mode 100644 app/Console/Commands/RegressLikesField.php diff --git a/app/Console/Commands/MigrateCloset.php b/app/Console/Commands/MigrateCloset.php deleted file mode 100644 index 37c2f695..00000000 --- a/app/Console/Commands/MigrateCloset.php +++ /dev/null @@ -1,66 +0,0 @@ -info('Nothing to do.'); - - return; - } - - $this->info('We will migrate all closets data. Please wait...'); - - $rows = DB::table('closets')->select('*')->get(); - $bar = $this->output->createProgressBar($rows->count()); - - $rows->map(function ($row) use ($bar) { - $closet = User::find($row->uid)->closet(); - collect(json_decode($row->textures, true))->each(function ($item) use ($closet) { - $closet->attach($item['tid'], ['item_name' => $item['name']]); - }); - $bar->advance(); - }); - - Schema::drop('closets'); - $bar->finish(); - $this->info("\nCongrats! Everything are done."); - } -} diff --git a/app/Console/Commands/MigratePlayersTable.php b/app/Console/Commands/MigratePlayersTable.php deleted file mode 100644 index fa7a0bc4..00000000 --- a/app/Console/Commands/MigratePlayersTable.php +++ /dev/null @@ -1,84 +0,0 @@ -info('No need to update.'); - - return; - } - - $players = Player::where('tid_skin', -1)->get(); - $count = $players->count(); - - if ($count == 0) { - $this->dropColumn(); - $this->info('No need to update.'); - - return; - } - - $this->info('We are going to update your `players` table. Please wait...'); - $bar = $this->output->createProgressBar($count); - - $players->each(function ($player) use ($bar) { - $player->tid_skin = $player->preference == 'default' - ? $player->tid_steve - : $player->tid_alex; - $player->save(); - - $bar->advance(); - }); - - $this->dropColumn(); - - $bar->finish(); - - $this->info("\nCongratulations! We've updated $count rows."); - } - - private function dropColumn() - { - Schema::table('players', function (Blueprint $table) { - $table->dropColumn(['tid_steve', 'tid_alex', 'preference']); - }); - } -} diff --git a/app/Console/Commands/RegressLikesField.php b/app/Console/Commands/RegressLikesField.php deleted file mode 100644 index aee33e07..00000000 --- a/app/Console/Commands/RegressLikesField.php +++ /dev/null @@ -1,44 +0,0 @@ -info('We are going to update your `textures` table. Please wait...'); - $textures = Texture::all(); - $bar = $this->output->createProgressBar($textures->count()); - - $textures->each(function ($texture) use ($bar) { - $texture->likes = $texture->likers->count(); - $texture->save(); - $bar->advance(); - }); - - $bar->finish(); - $this->info("\nCongratulations! Table was updated successfully."); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2f52666a..8dadbaf3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -15,10 +15,7 @@ class Kernel extends ConsoleKernel \Laravel\Passport\Console\KeysCommand::class, Commands\KeyRandomCommand::class, Commands\SaltRandomCommand::class, - Commands\MigratePlayersTable::class, - Commands\MigrateCloset::class, Commands\BsInstallCommand::class, - Commands\RegressLikesField::class, Commands\PluginEnableCommand::class, Commands\PluginDisableCommand::class, ];