Laravel 1071 Specified key was too long

出现错误

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter
table `users` add unique `users_email_unique`(`email`))

解决方法:参考了

可以在 AppServiceProvider.php 文件(此文件在app/Providers/下)里的 boot 方法里设置一个默认值:

use Illuminate\Support\Facades\Schema;
public function boot()
{
    //
    Schema::defaultStringLength(191);
}

猜你喜欢

转载自www.cnblogs.com/code1521/p/10777917.html