Aligned command class code

- Aligned usage of injecting through handler.
- Aligned handler return type.
- Aligned argument and arg desc format.
- Aligned lack of constructor.
This commit is contained in:
Dan Brown
2023-05-24 12:59:50 +01:00
parent 0704f1bd0d
commit c0620da9f8
17 changed files with 86 additions and 250 deletions

View File

@@ -12,7 +12,8 @@ class UpgradeDatabaseEncoding extends Command
*
* @var string
*/
protected $signature = 'bookstack:db-utf8mb4 {--database= : The database connection to use.}';
protected $signature = 'bookstack:db-utf8mb4
{--database= : The database connection to use}';
/**
* The console command description.
@@ -21,20 +22,11 @@ class UpgradeDatabaseEncoding extends Command
*/
protected $description = 'Generate SQL commands to upgrade the database to UTF8mb4';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
public function handle(): int
{
$connection = DB::getDefaultConnection();
if ($this->option('database') !== null) {
@@ -48,9 +40,11 @@ class UpgradeDatabaseEncoding extends Command
$key = 'Tables_in_' . $database;
foreach ($tables as $table) {
$tableName = $table->$key;
$this->line('ALTER TABLE `' . $tableName . '` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->line("ALTER TABLE `{$tableName}` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
}
DB::setDefaultConnection($connection);
return 0;
}
}