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 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
解決方法
修改 app/Providers/AppServiceProvider.php檔案中新增如下內容:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
}
public function boot()
{
Schema::defaultStringLength(191);
}
}
修改部分
Schema::defaultStringLength(191);
本作品採用《CC 協議》,轉載必須註明作者和本文連結