voyager: Can't install Voyager on a fresh new Laravel projet !

  • Laravel Version: 5.5
  • Voyager Version: 1.0
  • PHP Version: 7.0.11
  • Database Driver & Version: MySQL 5.7.14

Description:

I have a fresh new installation of Laravel 5.5, i added Voyager’s dependency via “composer require tcg/voyager”.

The problem occur when i try to install voyager with “php artisan voyager:install” so i have these errors :

1-   [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 `translations` add unique `translati
  ons_table_name_column_name_foreign_key_locale_unique`(`table_name`, `column_name`, `foreign_key`, `locale`))
2 - [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is ```
1000 bytes

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

Any idea how to solve this !

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 16 (1 by maintainers)

Most upvoted comments

This happens to me when I tried to install voyager. After few digging I found these two answers which working try this on the /config/database.php

‘mysql’ => [ …, …, ‘engine’ => null, ]

to ‘mysql’ => [ …, …, ‘engine’ => ‘InnoDB’, ]

its work for me.

@vaggelis2018, while you’re technically correct, it’s still ours to fix since it’s directly triggered by something we ship. We can’t require users to change DBMS simply because we don’t want to optimize our table indexes. At the same time, the burden of properly managing your DBMS, does fall on the user, which is why this is a complex issue.

I believe the only reasonable fixes we could do are:

  1. document the issue and suggested workarounds
  2. change our indices so this doesn’t happen
  3. remove the index altogether

I’m going to throw out number 3, simply because it’ll lead to inefficiency in the application and removes a point of validation (it’s a combination of 4 fields set to unique).

Number 2 is possible, but takes a bit of research and planning. There may be some optimizations we could take (maybe we don’t need all 4 fields in that unique index)

Number 1 should be done regardless. @mark has been fielding this question a lot in slack. @mark, could you post the suggested work-arounds that you’ve been using? Also, we should get those documented.

Thanks!

This is not a voyager issue. If you update to Maria DB 10.2 this issue will be solved. Please close this thread.

i made this change and worked for me `$table->string(‘table_name’)->unique(); $table->string(‘column_name’)->unique(); $table->integer(‘foreign_key’)->unsigned()->unique(); $table->string(‘locale’)->unique();

        $table->text('value');

        //$table->unique(['table_name', 'column_name', 'foreign_key', 'locale']);`

thanks @Jaikangam93

it worked for me too, by default my database was using MYISAM.

Change it to InnoDB in config/database.php was the only fix that worked.

@HamzaAhmad932, it sets the database table storage engine to InnoDB. Specifics on that are available online and have nothing to do with Voyager.

I’m going to close this now. The original issue has been discussed ad nauseam in the laravel community, and is caused by a change made in newer mysql versions.

I use MySQL 5.7.24 and have the issue too. Like Jaikangam93 said, I edit the file in config/database.php

‘mysql’ => [ … ‘engine’ => ‘InnoDB ROW_FORMAT=DYNAMIC’, //instead of null, problem solved … ],

No worries. I definitely understand the frustration.

The original issue is because laravel(or one of it’s dependencies) changed the default character encoding used, which means each character requires 4 bytes instead of 1-2, leading to less available space for indices to make use of.

The reason I say this is our problem to fix is because we use a (unique) index that combines 4 fields, whose total length violates the size limit.

This was supposedly fixed in MySQL 5.7.7(or mariadb 10.2.2), but we need to be cognizant of what we’re using for indices.

Hi, if you set utf8mb4 as default collation for db, try to set default string length to 191 with Schema facade, then install voyager