I have a database table in my Laravel 8 Project to which I want to assign MyISAM. I do this with this line $table->engine = "MyISAM";
in the migration file. When I start php artisan migrate
I get the following error message:
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 `view_counters` add index
`view_counters_countable_type_countable_id_index`(`countable_type`,
`countable_id`))
Thats my migration file:
Schema::create('view_counters', function (Blueprint $table) {
$table->engine = "MyISAM";
$table->id();
$table->morphs('countable');
$table->integer('views')->default(0);
});
I have already read that in this case you can add Schema::defaultStringLength(191)
to the boot() method of the AppServiceProvider to avoid this error.
QUESTION: I would like to know what exactly the error message means? Maybe my approach to write the database engine in the migration is wrong. Who knows more?