Nacim Idjakirene
Nacim Idjakirene

Reputation: 1931

Errors in migration when installing the Laravel Voyager package

i have i brand new installation of Laravel 5.5, but when i try to install the Voyager admin panel i have this error :

  [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`))

Config

PHP version : 7.0.10 MYSQL version : 5.7.14

CODE UPDATE

I think i have found the concerned code :

        Schema::create('translations', function (Blueprint $table) {
        $table->increments('id');

        $table->string('table_name');
        $table->string('column_name');
        $table->integer('foreign_key')->unsigned();
        $table->string('locale');

        $table->text('value');

        $table->unique(['table_name', 'column_name', 'foreign_key', 'locale']); // SOURCE OF THE ERROR ?
    });

Upvotes: 2

Views: 895

Answers (3)

Adam
Adam

Reputation: 28979

This is a known issue.

If you do not use the muli-language features from Voyager simply uncomment the line in *******************_create_translations_table

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

or try to update your MySql Database to 7.x

Upvotes: 0

Ezatla
Ezatla

Reputation: 195

You need to Update the "config/database.php" for 'mysql'.

'engine' => null

To

'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',

also Update the "app/Providers/AppServiceProvider.php"

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // Specified key was too long error, Laravel News post:
        Schema::defaultStringLength(191);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

and run these commands in your project folder.

php artisan cache:clear

php artisan config:clear

php artisan voyager:install --with-dummy

Upvotes: 3

mrg
mrg

Reputation: 88

The total length of your index is too long.

The column on which the unique index is added shouldn't be such long like VARCHAR columns, because the index will be very bulky and inefficient.

Upvotes: 0

Related Questions