Waavi/translation

Migration error: Specified key was too long; max key length is 1000 bytes

mariavilaro opened this issue · 6 comments

When running migrations I got this error:

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
QL: alter table `translator_translations` add unique 
`translator_translations_locale_namespace_group_item_unique`(`
locale`, `namespace`, `group`, `item`))

This was already reported years ago here #6 but it was closed and I don't understand how can I work around it?

Testing things I noticed that if I reduce the size of the 3 strings from 150 to 100:

        $table->string('namespace', 100)->default('*');
        $table->string('group', 100);
        $table->string('item', 100);

It works ok

Hello any tip please? I would like to use this package but I don't really know how to solve this problem without changing the code. Is it some mysql config?

@mariavilaro This should be fixed in the latest release.

No, I updated to latest version (2.3.4) and I still got the same error, I don't understand why.

C:\wamp\www\hitachi-backend>php artisan migrate
Migration table created successfully.

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
  QL: alter table `translator_translations` add unique `translator_translations_locale_namespace_group_item_unique`(`
  locale`, `namespace`, `group`, `item`))


In PDOStatement.php line 107:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes


In PDOStatement.php line 105:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

Ok I found it, it was that my MySQL was using MyISAM as default engine, and max key length there is 1000 bytes. Changed to InnoDB and now is working ok.

For whoever founds this when looking for this error, change this line in your my.ini file:

; The default storage engine that will be used when create new tables
default-storage-engine=InnoDB

Yep that was the issue in my case too!