mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-02-23 14:59:07 +08:00
Remove v4 migration commands
This commit is contained in:
parent
fab3da8f7f
commit
eed205b7f9
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Schema;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class MigrateCloset extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'bs:migrate-v4:closet';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migrate the closet for v4';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! Schema::hasTable('closets')) {
|
||||
$this->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.");
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Schema;
|
||||
use App\Models\Player;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class MigratePlayersTable extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'bs:migrate-v4:players-table';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migrate the players table for v4';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! Schema::hasColumn('players', 'tid_steve')) {
|
||||
$this->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']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Texture;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RegressLikesField extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'bs:migrate-v4:likes';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Apply fixes for `likes` field of `textures` table.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->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.");
|
||||
}
|
||||
}
|
@ -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,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user