SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
Description
When running 'php artisan migrate' the migrations halt when un able to create an unique key for both the features and the related table.
While I understand that it's due to the charset / collation taking up more bytes for emojis, I have no idea how to resolve this without editing both migration files and adjusting the size for fields using string size 255.
Please advice how I can resolve this.
Steps to reproduce
By running migrate:fresh on Laravel Breeze with the described versions.
Expected result
Migrations finish without any issues.
Actual result
When I run the migrations I get the following error with migration 2020_02_09_000008_create_twill_default_features_table
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table features add unique features_unique(featured_id, featured_type, bucket_key))
the same happens for 2020_02_09_000010_create_twill_default_related_table
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table related add unique related_unique(subject_id, subjec t_type, related_id, related_type, browser_name))
Versions
Twill: 2.9.0 Larvel version: 9.19 Php version: 8.1 Mysql version: 8.0.27 Mysql charset: utf8mb4 Mysql collation: utf8mb4_unicode_ci
Hi @gglerum, I'm a bit surprised about this, is your MySQL db using the MyISAM engine instead of InnoDB, potentially?
Hi @ifox, you were right. The db engine was indeed set to MyISAM. Strangely enough changing the db engine in the "my.ini" did not work. I had to set it in the config.
/config database.php
...
'mysql' => [
...
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
...
]
...
This also made Schema::defaultStringLength(190); in the AppServiceProvider boot method unnecassery.
Thnx for the clue!