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

时间:2014-10-16 05:06:53

标签: php mysql laravel

我在使用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');
        }    
    }

1 个答案:

答案 0 :(得分:1)

整数列的调用没有长度(不像纯mysql那样)。所以就这样称呼:

$table->integer ('active');

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