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'