我安装laravel 5.5并且当我运行PHP artisan migrate时显示我的错误
[Illuminate\Database\QueryException]
sqlSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQ
L: alter tableusers
add uniqueusers_email_unique
(
我在AppServiceProvider.PHP上添加了以下代码
public function boot() { Schema::defaultStringLength(191); //Solved by increasing StringLength }
然后告诉我这个错误
[Illuminate\Database\QueryException]
sqlSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for ‘created_at’ (sql: create table(
password_resetstoken
varchar(191) not null,created_at
timestamp not null) de
fault character set utf8mb4 collate utf8mb4_unicode_ci)
解决方法
你可以使用nullableTimestamps()而不是timestamps()
要么
$table->timestamp('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
请查看以下参考链接: