From c3d7f728eef30c46ad69b50068792093d538ff45 Mon Sep 17 00:00:00 2001 From: Arthur Pariente Date: Wed, 10 Jul 2024 18:26:21 +0200 Subject: [PATCH] Fix failsafe for db charset --- .../migrations/2024_07_09_210356_update_db_charset.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Database/migrations/2024_07_09_210356_update_db_charset.php b/app/Database/migrations/2024_07_09_210356_update_db_charset.php index 9d1918358..33df77f35 100644 --- a/app/Database/migrations/2024_07_09_210356_update_db_charset.php +++ b/app/Database/migrations/2024_07_09_210356_update_db_charset.php @@ -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; }