vendredi 1 avril 2016

Laravel 5.0, migration: how to make integer not a primary key?

I would like to migrate a table with the elements below.

public function up() {
    Schema::create('users', function(Blueprint $table) {
        $table->increments('id');
        $table->integer('LoginID', 9)->unsigned();
        $table->string('username');
        $table->string('email')->unique();
        $table->string('password', 60)->unique();
        $table->rememberToken();
        $table->timestamps();
    });
}

However, I have kept dealing with the error below. Does anyone know how to make integer "LoginID not a primary key so that I can migrate the table below? Any advice appreciated. Thanks in advance.

[Illuminate\Database\QueryException]                                                                               
  SQLSTATE[HY000]: General error: 1 table "users" has more than one primary key (SQL: create table "users" ("id" integer not null primary key autoincrement, "LoginID" integer not null primary key autoincrement, "username" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar null, "created_at" date time not null, "updated_at" datetime not null))    



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire