Follower

2019年9月6日 星期五

【疑難雜症─PHP〈Laravel〉】SQLSTATE[42000] Syntax error or access violation: 1071 Specified key was too long

問題〈錯誤訊息〉: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))




解答:
在「AppServiceProvider.php」的boot中加入以下程式碼...

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


參考資料:https://laravel-china.org/articles/4195/laravel-54-common-error-specified-key-was-too-long

沒有留言:

張貼留言