mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-03-01 11:19:40 +03:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user