0
我想打表遷移, 但是當我執行有錯誤按摩用戶ID成爲主鍵和自動增量由它的自我
Incorrect table definition; there can be only one auto column and it must be defined as key
,但我沒有設置用戶ID爲增量和主鍵,爲什麼?
我是一個初學者反正 這裏是我的代碼
Schema::create('orders', function(Blueprint $table){
$table->increments('order_id');
$table->dateTime('order_date');
$table->integer('order_status')->default(0);
$table->integer('user_id', 10)->unsigned();
$table->string('npk_user_approval', 10);
$table->string('npk_ga_approval', 10);
$table->dateTime('approval_user_at')->nullable();
$table->dateTime('approval_ga_at')->nullable();
$table->dateTime('reject_user_at')->nullable();
$table->dateTime('reject_ga_at')->nullable();
$table->dateTime('created_at')->nullable();
$table->string('created_by', 50)->nullable();
$table->dateTime('updated_at')->nullable();
$table->string('updated_by', 50)->nullable();
$table->foreign('user_id')->references('id')->on('users');
});
您使用的是哪個版本的Laravel? – Gadzhev
@Gadzhev我使用的是5.3版本 –