我正在尝试在Laravel-5中更改mysql DB的编码,我已经尝试使用迁移,按照这个示例:https://slashdot.io/blog/adding-emoji-support-to-your-blog-948181198 - 然而,没有任何更新,字符集/编码仍然保持原样。
是否可能使用迁移来实现这一点?还是我需要编写一个单独的脚本?
迁移(为了完整起见)
是否可能使用迁移来实现这一点?还是我需要编写一个单独的脚本?
迁移(为了完整起见)
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::raw('ALTER TABLE homestead.survey_responses CONVERT TO CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci');
DB::raw('REPAIR TABLE homestead.survey_responses');
DB::raw('OPTIMIZE TABLE homestead.survey_responses');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::raw('ALTER TABLE homestead.survey_responses CONVERT TO CHARACTER SET = utf8 COLLATE utf8_unicode_ci');
DB::raw('REPAIR TABLE homestead.survey_responses');
DB::raw('OPTIMIZE TABLE homestead.survey_responses');
}
上述迁移运行时没有出现错误,但不幸的是它什么也没做。