I have created the tables in the database, but it shows me the error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
.
How do I fix this?
I have created the tables in the database, but it shows me the error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
.
How do I fix this?
This happens because Laravel changed the default value of the fields. To fix this, just go to the file app/Providers/AppServiceProvider.php
and add the following code:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Another way to solve is to add the index name in the second parameter:
$table->string('seu_campo')->unique(null,'chave');