0

Created new Laravel 5.2.8 project.

When I want do predefined migration, I get an errors:

[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

Migration:

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

How to solve this problem?

1 Answers1

0

Error is exactly telling you what's wrong. See your CREATE TABLE statement; you can't have two columns with timestamp and default to 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;
Rahul
  • 76,197
  • 13
  • 71
  • 125