Laravel Migrations - Issues while creating timestamps(Laravel 迁移 - 创建时间戳时的问题)
问题描述
I am trying to run migrations on my Laravel instance. They are just the default migrations (users and password resets) but when it tries to make the timestamps it throws this error:
[IlluminateDatabaseQueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: create table `
users` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) n
ot null, `password` varchar(60) not null, `remember_token` varchar(100) null, `created_at` timestamp default 0 not
null, `updated_at` timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci)
as well as a PDOException:
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'
How can I fix this?
Thanks.
This is due to MySQL not accepting zero as a valid default date and thus the table creation fails a constraint check on creation.
You probably have NO_ZERO_DATE
enabled in your MySQL configuration. Setting this to off will allow you to create the table or alternatively remove the default 0 value or change it to CURRENT_TIMESTAMP
.
You can find out more about this exact issue here: https://github.com/laravel/framework/issues/3602
这篇关于Laravel 迁移 - 创建时间戳时的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 迁移 - 创建时间戳时的问题
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01