Error:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: 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 767 bytes
Solution:
if (mysql version < 5.7.7 )
{
add the following code to 'AppServiceProvider.php' file.
use Illuminate\Support\Facades\Schema; public 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 767 bytes (SQL: 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 767 bytes
Solution:
if (mysql version < 5.7.7 )
{
add the following code to 'AppServiceProvider.php' file.
use Illuminate\Support\Facades\Schema; public function boot() { Schema::defaultStringLength(191); }
}
It is what I was searching for is really informative. Laravel migration It is a significant and useful article for us. Thankful to you for sharing an article like this.
ReplyDelete