laravel在进行数据迁移的时候,特殊字段太长报错
在执行数据迁移时,有时候会发生字段过长错误
php artisan migrate
报错
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified
key was too long; max key length is 1000 byte s (SQL: alter table
usersadd uniqueusers_email_unique(
解决办法
在App\Providers\AppServiceProvider.php里面引入
use Illuminate\Support\Facades\Schema;
然后在boot里面去使用它
public function boot()
{
Schema::defaultStringLength(191);
}

浙公网安备 33010602011771号