sunel / eav

Entity–attribute–value model (EAV) for Laravel Artisan
https://sunel.github.io/eav/
143 stars 39 forks source link

Mysql identifier names too long #44

Closed avido closed 3 years ago

avido commented 4 years ago

As laravel binds all the column names into one big identifier name it exceeds mysql limitation of 64 chars. Eg.

SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'sclera_attribute_groups_attribute_set_id_attribute_group_name_unique' is too long (SQL: alter table `sclera_attribute_groups` add unique `sclera_attribute_groups_attribute_set_id_attribute_group_name_unique`(`attribute_set_id`, `attribute_group_name`))

Proposed solution: Specify a name for each identifier eg. (create_attribute_groups_table.php)

$table->unique(['attribute_set_id', 'attribute_group_name'], 'set_id-group_name-unique');

sunel commented 4 years ago

@avido

You can also use this

https://laravel-news.com/laravel-5-4-key-too-long-error