{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/8857","labels_url":"https://api.github.com/repos/laravel/framework/issues/8857/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/8857/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/8857/events","html_url":"https://github.com/laravel/framework/issues/8857","id":79933610,"number":8857,"title":"Support for MySQL character set and collation at table and column level","user":{"login":"abepark01","id":7087312,"avatar_url":"https://avatars.githubusercontent.com/u/7087312?v=3","gravatar_id":"","url":"https://api.github.com/users/abepark01","html_url":"https://github.com/abepark01","followers_url":"https://api.github.com/users/abepark01/followers","following_url":"https://api.github.com/users/abepark01/following{/other_user}","gists_url":"https://api.github.com/users/abepark01/gists{/gist_id}","starred_url":"https://api.github.com/users/abepark01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abepark01/subscriptions","organizations_url":"https://api.github.com/users/abepark01/orgs","repos_url":"https://api.github.com/users/abepark01/repos","events_url":"https://api.github.com/users/abepark01/events{/privacy}","received_events_url":"https://api.github.com/users/abepark01/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/laravel/framework/labels/database","name":"database","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-23T19:33:52Z","updated_at":"2015-09-01T14:36:26Z","closed_at":"2015-09-01T14:36:26Z","body":"I saw a closed PR that addresses this [#879](https://github.com/laravel/laravel/pull/897/files), but it appears to be outdated.\r\n\r\n**Request**\r\nIt would be great to define mysql character set and collate at the table and column level to override the configuration when building models.\r\n\r\nI would love to help out and any guidance on how to approach this would be much appreciated!\r\n\r\n**Use Case**\r\nIn my localization project, I have a string_key column that needs to be case sensitive; so, I would set the character set to utf8 and collate utf8_bin.\r\nFor the translated text, I want to support full utf-8 character set and would want to use utf8mb4 and utf8mb4_collate_ci per https://mathiasbynens.be/notes/mysql-utf8mb4\r\n\r\nI would like to generate the following schema in MySQL:\r\n```sql\r\ndrop table if exists strings;\r\ncreate table strings (\r\n    string_id int unsigned auto_increment\r\n    , string_key varchar(255) character set utf8 collate utf8_bin\r\n    , string_text text character set utf8mb4 collate utf8mb4_unicode_ci\r\n    , primary key(string_id)\r\n    , unique key(string_key)\r\n) character set utf8mb4 collate utf8mb4_unicode_ci;\r\n```\r\n\r\nTweaking @bluematt's example...\r\n```php\r\nclass Create_Mixed_Charset_Table {\r\n\r\n    /**\r\n     * Make changes to the database.\r\n     *\r\n     * @return void\r\n     */\r\n    public function up()\r\n    {\r\n        Schema::create('strings', function($table) {\r\n            $table->charset('utf8mb4');\r\n            $table->collate('utf8mb4_unicode_ci'); \r\n\r\n            $table->increments('string_id');\r\n\r\n            // set the character set and collate at the column level\r\n            $table->string('string_key')->charset('utf8')->collate('utf8_bin');\r\n\r\n             // set the character set and collate at the column level\r\n            $table->text('string_value')->charset('utf8mb4')->collate('utf8mb4_unicode_ci');\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Revert the changes to the database.\r\n     *\r\n     * @return void\r\n     */\r\n    public function down()\r\n    {\r\n        Schema::drop('my_mixed_table');\r\n    }\r\n\r\n}"}}