rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

1071 Specified key was too long; max key length is 767 bytes #129

Closed francoism90 closed 7 years ago

francoism90 commented 7 years ago

EDIT: Solved!

Edit your /etc/mysql/my.cnf and add the following:

[mysqld]
..

# default character set and collation
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4

# utf8mb4 long key index
innodb_large_prefix = 1
innodb_file_format = barracuda
innodb_file_format_max = barracuda
innodb_file_per_table = 1

[mysql]
default-character-set=utf8mb4

With Laravel 5.4 the database scheme utf8mb4 is used by default, however it may not be enabled on the current MariaDB setup.

See http://stackoverflow.com/questions/23786359/laravel-migration-unique-key-is-too-long-even-if-specified for all needed steps.

acidjazz commented 6 years ago

@francoism90 I think we should re-open this, there are lots of situations where we don't have access to this kind of stuff, aka Aurora.

rtconner commented 6 years ago

So just truncate the tag after a certain number of characters?

francoism90 commented 6 years ago

@acidjazz Don't think this is needed, it should work for most (MySQL) users. :) @rtconner It has nothing to do with creating tags; you're unable to create the table.

acidjazz commented 6 years ago

Well I think we should at least add to the documentation that if this comes up they'll need to add

use Illuminate\Support\Facades\Schema;

...

public function boot()
{
    Schema::defaultStringLength(191);
}

to their AppServiceProvider.php