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 迁移 - 创建时间戳时的问题
基础教程推荐
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01