Laravel 5 database migrate issue - Specified key was too long
Solution to the following error
//
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
QL: alter table `users` add unique `users_email_unique`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
//
To resolve the above issue
Open "app\Providers\AppServiceProvider.php"
Add the following code
//
use Illuminate\Support\Facades\Schema;
function boot()
{
Schema::defaultStringLength(191);
}
//
//
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
QL: alter table `users` add unique `users_email_unique`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
//
To resolve the above issue
Open "app\Providers\AppServiceProvider.php"
Add the following code
//
use Illuminate\Support\Facades\Schema;
function boot()
{
Schema::defaultStringLength(191);
}
//
Comments
Post a Comment