Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数据库迁移在为laravel 5的两个时间戳列设定种子时引发错误_Php_Mysql_Laravel 5_Create Table_Laravel Migrations - Fatal编程技术网

Php 数据库迁移在为laravel 5的两个时间戳列设定种子时引发错误

Php 数据库迁移在为laravel 5的两个时间戳列设定种子时引发错误,php,mysql,laravel-5,create-table,laravel-migrations,Php,Mysql,Laravel 5,Create Table,Laravel Migrations,我扩展了默认迁移,为我的用户表添加了一些额外的表字段 我想在处创建字段,并在处更新字段,将时间戳作为值 这是我的密码 <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void

我扩展了默认迁移,为我的用户表添加了一些额外的表字段

我想在处创建
字段,并在
处更新
字段,将
时间戳
作为值

这是我的密码

<?php

 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;

 class CreateUsersTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('users', function(Blueprint $table)
    {
        $table->bigIncrements('id');
                    $table->bigInteger('group_id');
        $table->string('fname',255);
        $table->string('lname',255);
        $table->string('email',255)->unique();
        $table->string('password', 60);
        $table->boolean('active');
        $table->string('gravtar',255)->nullable();
        $table->rememberToken();
        $table->timestamps('created_at');
        $table->timestamps('updated_at');

    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('users');
}

}
请看,我只有一个名为
的列是在
处创建的,所以这个异常毫无意义。 然而,当我删除其中一个timestamp字段时,表就被迁移了

我不知道是什么导致了这种情况?

timestamps()方法同时添加了created_at和updated_at列。此外,此方法不接受任何参数


只需使用
$table->timestamp('col_name')
时间戳

[PDOException]
SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'created_at'