gpt4 book ai didi

php - Laravel 迁移错误

转载 作者:行者123 更新时间:2023-11-29 21:37:56 24 4
gpt4 key购买 nike

创建了新的 Laravel 5.2.8 项目。

当我想要进行预定义迁移时,出现错误:

[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURREN
T_TIMESTAMP in DEFAULT or ON UPDATE clause (SQL: create table `users` (`id` int unsigned not null auto_increment pr
imary key, `name` varchar(255) not null, `email` varchar(255) not null, `password` varchar(60) not null, `remember_
token` varchar(100) null, `created_at` timestamp default CURRENT_TIMESTAMP not null, `updated_at` timestamp default
CURRENT_TIMESTAMP not null) default character set utf8 collate utf8_unicode_ci)



[PDOException]
SQLSTATE[HY000]: General error: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURREN
T_TIMESTAMP in DEFAULT or ON UPDATE clause

迁移:

Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});

如何解决这个问题?

最佳答案

错误准确地告诉你出了什么问题。查看您的CREATE TABLE语句;您不能有两列带有 timestamp 且默认为 CURRENT_TIMESTAMP

SQL:

create table `users` (`id` int unsigned not null auto_increment pr
imary key,
`name` varchar(255) not null,
`email` varchar(255) not null,
`password` varchar(60) not null,
`remember_
token` varchar(100) null,
`created_at` timestamp default CURRENT_TIMESTAMP not null, <-- here
`updated_at` timestamp default CURRENT_TIMESTAMP not null) <-- here
default character set utf8 collate utf8_unicode_ci;

关于php - Laravel 迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34765053/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com