I use Lumen 5.6 and mysql. when i type "php artisan migrate" following error occur:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t
oo long; max key length is 767 bytes (SQL: alter table `users` add unique `
users_email_unique`(`email`))
I put following code into "boot" method in the AppServiceProvider
Schema::defaultStringLength(191);
but I didn't achieve to any success.
$app->register(App\Providers\AppServiceProvider::class);
AppServiceProvider
class:public function boot()
{
Schema::defaultStringLength(191);
}
you just need one more step
go to app.php on bootstrap folder and uncomomment or modif this line
// $app->register(App\Providers\AppServiceProvider::class);
to this code
$app->register(App\Providers\AppServiceProvider::class);
have a good day
You need couple of things to do. I also faced this issue and fixed it by following these two steps
Go to app.php in bootstrap directory and uncomment or modify this line.
// $app->register(App\Providers\AppServiceProvider::class);
Now you need to define boot()
function in AppServiceProvider
file
public function boot()
{
Schema::defaultStringLength(191);
}
Then you are good to go!
Go to config in file database.php
then edit
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With