【发布时间】:2020-06-11 12:29:25
【问题描述】:
我正在尝试更改 Laravel-5 中 mysql 数据库的编码,我尝试过迁移,遵循以下示例: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');
}
上述迁移运行,没有错误,但不幸的是什么也没做。
【问题讨论】:
标签: php mysql eloquent laravel-5