我想用下面的元素移植一張表格。Laravel 5.0,遷移:如何使整數不是主鍵?
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();
});
}
但是,我一直在處理下面的錯誤。 有誰知道如何使整「登錄ID不是主鍵,這樣我可以遷移見下表?任何意見讚賞。在此先感謝。
[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))
有東西掉。您所做的遷移中沒有任何內容會導致LoginID成爲自動遞增主鍵。 – patricus
我不知道原因,但幾個小時後才奏效。 – ILoveBaymax