我安装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'));
请查看以下参考链接:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。