/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('xx', function (Blueprint $table) {
//需要添加的代码
$table->increments('id');
$table->text('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('xx');
}
执行命令(数据库中生成一个 表结构 xx)
php artisan migrate
执行失败
提示只能有一个自动增长的主键 因为在用数据迁移方法创建表时 int 类型无法指定长度,如果有两个字段类型都为 int ,就会产生这样的错误 解决办法为:使用 big,small,tiny 这几种 int 类型,避免在创建的时候主键冲突