Skip to content

Commit

Permalink
Fix failsafe for db charset
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpar06 committed Jul 10, 2024
1 parent f5026ea commit c3d7f72
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public function up()
}

// Check the current charset
$connection = DB::connection()->getPdo();
$statement = $connection->query("SHOW VARIABLES LIKE 'character_set_connection'");
$result = $statement->fetch(PDO::FETCH_ASSOC);
$query = DB::table('information_schema.SCHEMATA')
->select('default_character_set_name')
->where('schema_name', config('database.connections.mysql.database'))
->first();

if ($result['Value'] === 'utf8mb4') {
if ($query?->default_character_set_name === 'utf8mb4') {
return;
}

Expand Down

0 comments on commit c3d7f72

Please sign in to comment.