From 5fe115ac68550914889bbd46534e86098c1cfeee Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 2 Nov 2023 14:10:01 +0800 Subject: [PATCH] Fixes unable to create MySQL database with `null` collation using `Schema::createDatabase()` Signed-off-by: Mior Muhammad Zaki --- src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 7f940b95f975..61192ab26321 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -43,11 +43,13 @@ class MySqlGrammar extends Grammar */ public function compileCreateDatabase($name, $connection) { + $collation = $connection->getConfig('collation'); + return sprintf( 'create database %s default character set %s default collate %s', $this->wrapValue($name), $this->wrapValue($connection->getConfig('charset')), - $this->wrapValue($connection->getConfig('collation')), + ! empty($collation) ? $this->wrapValue($collation) : $collation, ); }