gpt4 book ai didi

php - Laravel 迁移在表中分配 2 个主键

转载 作者:行者123 更新时间:2023-11-29 00:08:29 25 4
gpt4 key购买 nike

我的 laravel 迁移有问题,我的 laravel 迁移文件中有 tqo 整数,当我尝试迁移时,它报告我错误,说迁移包含 2 个主键。有没有人对此有任何想法。帮助将不胜感激。

<?php    
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLoginTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up(){
Schema::create('login', function(Blueprint $table)
{
$table->engine ='InnoDB';
$table->increments('id');
$table->string ('email', 255);
$table->string ('username', 255);
$table->string ('password', 255);
$table->string ('password_temp', 255);
$table->string ('code', 255);
$table->integer ('active', 11);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('login');
}
}

最佳答案

整数列被称为没有长度(不像在纯 mysql 中)。所以就这样调用它:

$table->integer ('active');

它会起作用的。文档:http://laravel.com/docs/4.2/schema#adding-columns

关于php - Laravel 迁移在表中分配 2 个主键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26396592/

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