讓我說我已經在我的MySQL數據庫中有一張表,並且我想向它添加列。要做到這一點,我做它像下面這樣:在Laravel遷移中更改表格時,是否有更簡單的方法來設置列的順序?
Schema::table('mytable', function($table) {
$table->integer('my_special_integer')->after('previous_column');
$table->text('my_special_text')->after('my_special_integer');
$table->string('my_special_string')->after('my_special_text');
/*Some many other field*/
$table->string('my_last_column_to_add')->after('my_second_last_column');
}
有沒有一種較少重複的方式,如果我只是想輸入一定以前的專欄後一堆列?
我並不認爲這能起到什麼作用,除非你使用的是原始的SQL語句,而不是laravel幫手。 – cytsunny