I am using Laravel 5.3 and I have already set up my production server. All database migrations have already been created using the following database configuration:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ],
But now some of my users have reported that they get an error when trying to save a form that has emoji icons .. After searching, I found out that I need to install mysql charset in utf8mb4 for this to work, so my configuration should have been with something like this:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ],
Since this is on a production server, I cannot do migrate:refresh . So my questions are:
- How can I modify an existing database that I created using laravel migration to use
utf8mb4 instead of utf8 , and also update laravel on the same? Is there an easier way to do this? - If possible, I better install
utf8mb4 for all tables or use only for two columns of the table, where I will really use emoji.
Thank you for your help.