繁体   English   中英

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

[英]Laravel migration assigns 2 primary key in a table

我在laravel迁移中遇到问题,我在laravel迁移文件中有tqo interger,当我尝试迁移时,它向我报告错误,指出该迁移包含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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM