in app/Console/Commands/MigrateDatabaseCollation.php [34:70]
public function handle()
{
if ($this->confirmToProceed()) {
try {
$connection = DBHelper::connection();
if ($connection->getDriverName() != 'mysql') {
return;
}
$databasename = $connection->getDatabaseName();
$schemata = $connection->table('information_schema.schemata')
->select('DEFAULT_CHARACTER_SET_NAME')
->where('schema_name', '=', $databasename)
->get();
$schema = $schemata->first()->DEFAULT_CHARACTER_SET_NAME;
if (config('database.use_utf8mb4') && $schema == 'utf8') {
$this->line('Migrate to utf8mb4 schema collation');
$this->toUtf8mb4($connection, $databasename);
} elseif (! config('database.use_utf8mb4') && $schema == 'utf8mb4') {
$this->line('Migrate to utf8 schema collation');
$this->toUtf8($connection, $databasename);
} else {
$this->info('Nothing to migrate, everything is ok.');
}
} catch (\Exception $e) {
$this->error(' ');
$this->error(' Check if the DB_USE_UTF8MB4 variable in .env file is correctly set ');
$this->error(' ');
$this->info('');
throw $e;
}
}
}