如何在Laravel迁移中的特定列之后排序多个新列

如何在Laravel迁移中的特定列之后排序多个新列,laravel,Laravel,有什么好办法吗?目前,我是按照我想要的相反顺序列出列的,如下所示: Schema::table('some_table', function($table){ $table->string('new_col_2')->after('existing_col'); //How to specify that this should come after new_col_1? $table->string('new_col_1')->after('existi

有什么好办法吗?目前,我是按照我想要的相反顺序列出列的,如下所示:

Schema::table('some_table', function($table){
    $table->string('new_col_2')->after('existing_col'); //How to specify that this should come after new_col_1?
    $table->string('new_col_1')->after('existing_col');
});

如果存在
existing\u col
,我认为可以按“正常”顺序调用您创建的下一列:

Schema::table('some_table', function($table){
    $table->string('new_col_1')->after('existing_col');
    $table->string('new_col_2')->after('new_col_1');
});
您是否尝试过:

Schema::table('some_table', function($table){
  $table->string('new_col_1')->after('existing_col');
  $table->string('new_col_2')->after('new_col_1');
}

另一个更好的选择是

Schema::table('some_table', function($table){
    $table->after('existing_col', function ($table) {
       $table->string('new_col_1');
       $table->string('new_col_2');
   });
});

出于个人好奇,我可以问你为什么db字段的顺序对你来说很重要吗?我想是因为有一个逻辑顺序可以让人更容易解析数据,你的意思是通过PHP管理员(或任何其他db查看器)直接在db中查看?是的,最好看到类似[id、名称、地址\行\ 1、地址\行\ 2、年龄、日期\创建]然后[地址行2,创建日期,年龄,地址行1,id,姓名]是的,刚刚意识到我输入了一个列名,这就是迁移失败的原因!