How to set auto increment into non primary key?
问题 How would I set a database auto increment field that is not a primary key on the creation method? The only way is using a raw query? DB::statement('ALTER TABLE table CHANGE field field INT(10)AUTO_INCREMENT'); 回答1: It is not implemented to do so. However, I found this over at the Laravel Forums: Schema::table('table', function(Blueprint $t) { // Add the Auto-Increment column $t->increments("some_column"); // Remove the primary key $t->dropPrimary("table_some_column_primary"); // Set the