user2550011
user2550011

Reputation: 13

Laravel migration assigns 2 primary key in a table

i am having a problem with laravel migration, i have tqo interger in my laravel migration file, when i try to migrate it reports me error saying that the migration contains 2 primary key. Does anyone have any idea about this. help would be appreciated.

<?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');
        }    
    }

Upvotes: 1

Views: 518

Answers (1)

Tom
Tom

Reputation: 3664

Integer columns are called without length (not like in pure mysql). So just call it like:

$table->integer ('active');

and it will work. Docs: http://laravel.com/docs/4.2/schema#adding-columns

Upvotes: 1

Related Questions